Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with Print extension #144

Closed
PeterWone opened this issue Sep 18, 2022 · 6 comments
Closed

Incompatible with Print extension #144

PeterWone opened this issue Sep 18, 2022 · 6 comments

Comments

@PeterWone
Copy link

This may be related to #137

I am the author of the Print extension, which among other things prints Markdown rendered.

I am interested in collaborating to resolve the incompatibility.

As you can see other Markdown extensions are able to render graphics in a compatible manner.

rendered md

While I've had only a cursory look at your code and haven't yet spun it up in the extension host, I'm a bit puzzled as to how it renders, I haven't yet spotted where that's done. The SMILES molecule in the sample above is rendered by the MathPix extension as SVG, which prints beautifully without pixelation.

@mjbvz
Copy link
Owner

mjbvz commented Dec 7, 2022

I suspect the issue is related to how we render. AFAIK mermaid can only run in browsers (mermaid-js/mermaid#3650). This means that the VS Code side of this extension does not actually do the rendering mermaid diagrams, instead we have to inject a script into the markdown preview that does the rendering of markdown source that we have pre-processed

I don't know how print is implemented but unless you are getting the rendered content of the markdown preview, the mermaid diagrams will not show up

@PeterWone
Copy link
Author

Basically it declares itself to be a markdown extension so it can capture a reference to the vscode markdownit instance, and it calls the render method on that, passing a string containing markdown.

@mjbvz
Copy link
Owner

mjbvz commented Dec 8, 2022

Yes that's why it doesn't work: after the markdown -> html step, the mermaid diagrams haven't been rendered yet. The rendering only happens once the diagrams are shown in a webview

Short of being able to run Mermaid in node, I don't think this is in scope of this extension. You can try either post-processing the html to render the diagrams or perhaps capturing the html after it has been rendered somewhere. Sorry I don't have a better answer for you

@mjbvz mjbvz closed this as completed Dec 8, 2022
@mjbvz mjbvz removed the help wanted label Dec 8, 2022
@PeterWone
Copy link
Author

PeterWone commented Dec 8, 2022

Eventually I send the HTML to a browser. What's the script I need to inject? or at least where should I look in your code

@mjbvz
Copy link
Owner

mjbvz commented Dec 8, 2022

This script:

"./dist-preview/index.bundle.js"

But it may only work inside VS Code and not in browsers. You can always bring your own mermaid though if using this script is too difficult

@PeterWone
Copy link
Author

PeterWone commented Dec 8, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants