mjbvz / vscode-markdown-mermaid

Adds Mermaid diagram and flowchart support to VS Code's builtin markdown preview
https://marketplace.visualstudio.com/items?itemName=bierner.markdown-mermaid
MIT License
640 stars 115 forks source link

Better syntax error reporting #140

Closed msafronov closed 2 years ago

msafronov commented 2 years ago

Hi! )

I tried to add error display to the extension: https://github.com/mjbvz/vscode-markdown-mermaid/issues/129

Some details:

I managed to override the parseError method via mermaid.setParseErrorHandler / mermaid.parseError, but it is not working during the "bomb". As far as I understand, parseError calls only inside mermaid.init or mermaidAPI.parse, but the "bomb" explodes during the mermaid.render in the extension (by error throwing).

What I did:

I took the path of least resistance and wrapped mermaid.render in try..catch for error catching. I tried not to break the standard behavior of the mermaid library, just added the error message to the bomb.

It looks like this now:

demo1 demo2 demo3

Thanks!

mjbvz commented 2 years ago

Thanks for looking into this.

Does this PR fully address #129 or are there known issues with it?

msafronov commented 2 years ago

@mjbvz I only fixed #129

mjbvz commented 2 years ago

Thanks! Will publish update with this shortly