1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-29 19:13:59 +02:00
Helmut K. C. Tessarek a278c2c32a
Desktop, Mobile: Update Mermaid: 8.8.1 -> 8.8.4 (#4193)
```
Release Notes 8.8.4

    Re-align gantt chart dateFormat table with spaces (#1764) @AloisMahdal
    Docs/update edit this page (#1774) @sy-records
    Fixed typo in the docs (#1780) @manicki
    Move babel-eslint to devDependencies (#1772) @glensc
    Add Doscy to list of integrations (#1784) @gwatts
    Changed regex for multi-line state notes (#1773) @tomatoman25
    Add different id generators (#1787) @julianbei
    Bump highlight.js from 9.18.1 to 9.18.5 (#1789) @dependabot
    Fixed markdown error in Relationship Syntax (#1796) @kciter
    remove classDiagram duplicate options (#1786) @JiChao99
    Update copyright years (#1805) @BastianZim

🐛 Bug Fixes

    Add sans-serif to default font settings (#1776) @GDFaber
    ignore build files in dist folder (#1777) @GDFaber
    Narrow down console logging when flowchart subgraphs are added (#1782) @GDFaber
    Apply style settings to subgraphs in "flowchart" diagrams (#1781) @GDFaber

Release Notes 8.8.3

    Fix styling of links for new beta flowchart (#1730) @knsv
    Fix typo in pie.md (#1705) @hwine
    Fixing broken links and misspellings (#1727) @deining
    Fixed empty code examples (#1729) @Eraledm
    README: use stateDiagram-v2 (#1728) @alexislefebvre
    #1724 Adding fontawesome to edge labels (#1731) @knsv
    Fix broken links in gantt.md (#1703) @wontonst
    Replace fregante/setup-git-token with setup-git-user (#1735) @fregante
    Updated docs (#1739) @BastianZim
    1740 nested subgraps directions (#1741) @knsv
    Switching to Docsify and adding search (#1746) @NeilCuzon
    Fixed bad tertiary operator (#1743) @lishid
    fix broken links in README (#1749) @levlas

Release Notes 8.8.2

    1704 Revert to original behavior of nodes and subgraphs (#1709) @knsv

    There is some ambiguity about what subgraph a node belongs to when it appears in several subgraphs. Should it stick to the first subgraph it appears in, or should the last subgraph it gets added to be the one it belongs to. With this change the original behavior is retained.
```
2020-12-09 21:44:38 +00:00
..
2020-11-05 16:58:23 +00:00
2020-11-05 16:58:23 +00:00
2020-11-05 16:58:23 +00:00
2020-11-05 16:58:23 +00:00
2020-11-05 16:58:23 +00:00
2020-11-05 16:58:23 +00:00
2020-11-05 16:58:23 +00:00

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 } = require('joplin-renderer');

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 = new MarkupToHtml(options);
const result = await markupToHtml.render(MarkupToHtml.MARKUP_LANGUAGE_MARKDOWN, markdown, theme, options);

console.info('HTML:', result.html);
console.info('Plugin assets:', result.pluginAssets);

When calling render(), an object with the following properties is returned:

  • html: The rendered HTML code
  • pluginAssets: 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:

function loadPluginAssets(assets) {
	for (let i = 0; i < assets.length; i++) {
		const asset = assets[i];

		if (asset.mime === 'text/css') {
			const link = document.createElement('link');
			link.rel = 'stylesheet';
			link.href = 'pluginAssets/' + asset.name;
			document.getElementById('joplin-container-styleContainer').appendChild(link);
		}
	}
}

Development

Updating a markdown-it plugin

Whenever updating a Markdown-it plugin, such as Katex or Mermaid, make sure to run npm run buildAssets, which will compile the CSS and JS for use in the Joplin applications.

### Adding asset files

A plugin (or rule) can have any number of assets, such as CSS or font files, associated with it. To add an asset to a plugin, follow these steps:

  • Add the file under /assets/PLUGIN_NAME/your-asset-file.css
  • Register this file within the plugin using context.pluginAssets[PLUGIN_NAME] = [{ name: 'your-asset-file.css' }]

See katex.js for an example of how this is done.

Adding inline CSS

A plugin can ask for some CSS to be included inline in the rendered HTML. This is convenient as it means no extra file needs to be packaged. Use this syntax to do this:

context.pluginAssets[PLUGIN_NAME] = [
	{
		inline: true,
		text: ".my-css { background-color: 'green' }",
		mime: 'text/css',
	},
];