reox8623 downloadsRender Pikchr code blocks as diagrams, with a button to flip each one between the diagram and its source.
Draw diagrams in your notes with Pikchr, a small language for technical
diagrams. Write a pikchr code block and the diagram appears in its place, in Reading view and
Live Preview, on desktop and mobile.
```pikchr
arrow right 200% "Markdown" "Source"
box rad 10px "Markdown" "Formatter" "(markdown.c)" fit
arrow right 200% "HTML+SVG" "Output"
arrow <-> down 70% from last box.s
box same "Pikchr" "Formatter" "(pikchr.c)" fit
```
To install by hand instead, download main.js, manifest.json and styles.css from the
latest release into
<your vault>/.obsidian/plugins/pikchr-diagram-preview/, then enable the plugin.
Put Pikchr code in a code block tagged pikchr. The Pikchr user manual
explains the language. Text written with print appears above the diagram.
Add options in braces after pikchr:
```pikchr {caption="Figure 1: The formatter" align="center" alt="Two boxes joined by arrows"}
box "Markdown" fit
arrow
box "HTML" fit
```
| Option | What it does |
|---|---|
caption |
Text shown under the diagram. |
align |
left, center or right. |
alt |
A description read aloud by screen readers. |
class |
A CSS class, for styling the diagram with a CSS snippet. |
Put each value in quotes. Values are plain text, not Markdown. If an option is misspelled, it's ignored and the diagram still appears.
Diagrams follow your theme. In a dark theme, lines and text are lightened just enough to read, filled shapes are darkened, and colours keep their hue. In a light theme, diagrams appear on a white card with their exact colours.
To always show the exact colours on a white card, turn off Follow dark themes in the plugin's settings.
| Setting | What it does |
|---|---|
| Render time limit | How long a diagram may take before it's shown as an error. 3 seconds by default, from 0.5 to 60. |
| Follow dark themes | On by default. Turn off to keep every diagram on a white card. |
| Debug logging | Writes ignored options to the developer console, to help find a typo. |
| Command | What it does |
|---|---|
| Show every diagram in this note | Switches every block in the note back from code to diagram. |
| Restart renderer | Starts the diagram engine afresh and redraws open notes. |
Diagrams are drawn on your device, inside Obsidian. The plugin doesn't connect to the internet, doesn't collect any data, and doesn't read or write any files.
Diagrams are drawn by Pikchr, created by D. Richard Hipp. The licenses of the software built into this plugin are listed in THIRD_PARTY_NOTICES.md.
Released under the MIT License. To build or change the plugin, see DEVELOPMENT.md.