Homepage    |    GitHub    |    API    |    FAQ

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.