Joplin Renderer
This is the renderer used by Joplin to render notes in Markdown or HTML format.
Installation
npm i -s joplin-renderer
Certain plugins require additional assets like CSS, fonts, etc. These assets are in the /assets
directory and should be copied to wherever the application can find them at runtime.
Usage
const MarkupToHtml = ; const options = {}; // The notes are rendered using the provided theme. The supported theme properties are in `defaultNoteStyle.js`// and this is what is used if no theme is provided. A `theme` object can be provided to override default theme// properties.const theme = {}; const markdown = "Testing `MarkupToHtml` renderer"; const markupToHtml = options;const result = await markupToHtml; console;console;
When calling render()
, an object with the following properties is returned:
html
: The rendered HTML codepluginAssets
: The assets required by the plugins
The assets need to be loaded by the calling application. For example this is how they are loaded in the Joplin desktop application:
{ for let i = 0; i < assetslength; i++ const asset = assetsi; if assetmime === 'text/css' const link = document; linkrel = 'stylesheet'; linkhref = 'pluginAssets/' + assetname; document; }