Skip to content

Commit

Permalink
All: Resolves #163: Added Mermaid support to desktop and mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Feb 28, 2019
1 parent e841ea8 commit a0e5947
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 384 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -39,6 +39,7 @@ node_modules
Tools/github_oauth_token.txt
_releases
ReactNativeClient/lib/csstojs/
ReactNativeClient/lib/rnInjectedJs/
ElectronClient/app/gui/note-viewer/fonts/
ElectronClient/app/gui/note-viewer/lib.js
Tools/commit_hook.txt
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -251,6 +251,24 @@ You can create a link to a note by specifying its ID in the URL. For example:

Since getting the ID of a note is not straightforward, each app provides a way to create such link. In the **desktop app**, right click on a note an select "Copy Markdown link". In the **mobile app**, open a note and, in the top right menu, select "Copy Markdown link". You can then paste this link anywhere in another note.

## Charts

You can create charts in Joplin using the [Mermaid syntax](https://mermaidjs.github.io/). To add such a graph, wrap the Mermaid script inside a "\`\`\`mermaid" code block like this:

```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```

This is how it would look with the Markdown on the left, and rendered graph on the right:

![Mermaid support in Joplin](https://joplin.cozic.net/images/Mermaid.png)

Note that Mermaid graphs are always rendered on a white background regardless of the current theme. This is because they can contain various colours that may not be compatible with the current theme.

## Math notation

Math expressions can be added using the [KaTeX notation](https://khan.github.io/KaTeX/). To add an inline equation, wrap the expression in `$EXPRESSION$`, eg. `$\sqrt{3x-1}+(1+x)^2$`. To create an expression block, wrap it as follow:
Expand Down
6 changes: 4 additions & 2 deletions ReactNativeClient/lib/MdToHtml_Mermaid.js
@@ -1,5 +1,4 @@
const { shim } = require('lib/shim');
const mermaid = require('mermaid');
const injectedJs = require('lib/rnInjectedJs/mermaid');

class MdToHtml_Mermaid {
Expand All @@ -14,7 +13,10 @@ class MdToHtml_Mermaid {
}

extraCss() {
return '';
// Force a white background because the graphs can have various colours
// that may not be compatible with the current theme. Also make it
// inline-block so that the div is the same size as the content.
return '.mermaid { background-color: white; display:inline-block; }';
}

injectedJavaScript() {
Expand Down

0 comments on commit a0e5947

Please sign in to comment.