Skip to content

Conversation

@neurolag
Copy link
Contributor

This PR fixes #116987

Since the introduction of the new feature for stabilizing images, passing an env-parameter to the markdown-it-parser became mandatory as seen here:

const env: RenderEnv = {
containingImages: []
};
const html = engine.renderer.render(tokens, {
...(engine as any).options,
...config
}, env);

As my extension uses vscode's markdown-it-parser, having to provide an env-object with pre-defined properties is quite inconvenient. For that reason I created this PR which makes passing an env-object optional as the necessary env.containingImages-property is created on the fly, if necessary, using a new initialize_vscode_image_stabilizer-rule.

@neurolag
Copy link
Contributor Author

In order to create this PR I had to update the @types/markdown-it package.
However, changes to yarn.lock files seem to be blocked.

Is there some workaround for such cases?

Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of changes here that seem unrelated to the original issue. These may be ok, but please submit them in a separate PR

Based on your description, it sounds like to prevent the crash, we just need to check if env is undefined in addImageStabilizer (the image stabilizer logic won't make any sense for external consumers anyways, so IMO it's fine to not support it here)

@neurolag neurolag requested a review from mjbvz February 19, 2021 21:26
@mjbvz mjbvz added this to the February 2021 milestone Feb 22, 2021
@mjbvz mjbvz merged commit cdd7066 into microsoft:main Feb 22, 2021
@mjbvz
Copy link
Collaborator

mjbvz commented Feb 22, 2021

Thanks! This will be in the next VS Code insiders build and is scheduled to go out with VS Code 1.54

@neurolag
Copy link
Contributor Author

Awesome thank you very much! ✨

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[markdown-language-features] Rendering a Document Containing Pictures Throws a TypeError

2 participants