Parse MD from within webview

So basically i need to parse markdown that is fetched by webview api call.

There seems be no markdown instance in webview.
So i think i gotta install whole markdown-it inside a plugin and parse content before sending it to view.

I'm just wondering if there's any better way.

You could use the @joplin/renderer package to get the same rendering as in the app, including resources. See for example how it's done in the server application: joplin/Application.ts at 1900ffe96d9ff2f913f60e9f8d36309241cc379a ยท laurent22/joplin ยท GitHub

You might also need to read settings to enable/disable the same plugins as the main renderer, if that's important at all.

1 Like

Thanks!

I'm getting error after creating instance of new MarkupToHtml({}) but i think its related to utf-8 - addressed by Desktop: Enforce utf-8 charset for plugin scripts by CalebJohn ยท Pull Request #4509 ยท laurent22/joplin ยท GitHub.

plugin_joplin.plugin.ambrt.embedSearch.js:8
Uncaught SyntaxError: Invalid regular expression: /[รŒโ‚ฌ-รยฏ]+$/: Range out of order in character class
at new RegExp ()

So marking as solved for now and waiting for new release.