benjypng / logseq-mermaid-plugin

Create mermaid diagrams in image format on-the-fly.
MIT License
94 stars 8 forks source link

fix: embedded HTML causes XML rendering failure #24

Open jamestelfer opened 1 month ago

jamestelfer commented 1 month ago

Diagrams with embedded line breaks (<br>) cause rendering errors unless they're properly converted to XML (<br/>). This will affect any other HTML that gets accidentally embedded.

Using the XMLSerializer is a generic fix, a lot better than trying to create a list of elements to fix.

Fixes #23.

Using a trick from the Mermaid CLI, see:

https://github.com/mermaid-js/mermaid-cli/blob/f235609053213226c733fa2d7caa87b2839991bb/src/index.js#L311-L312

Also: introduces an error handler that improves the error messaging given to the user, as well as extending error handling to the image rendering phase.