Code, formulas and diagrams
Notes aren’t only prose. Keep a command you always forget, write a formula properly, or sketch a process as a diagram, all in the same note, all drawn on your Mac without an internet connection.
Inline code
Wrap a short command, file name or setting in backticks, or select it and press ⌥⌘C:
Restart the router, then run `ping 1.1.1.1` to check.Restart the router, then run ping 1.1.1.1 to check.
Code blocks
For several lines, use a code block. Press ⌃⌘C, or type three backticks on a line of their own: Varlig adds the closing backticks for you and suggests a language. Choosing a language, such as python or swift, gives the code its syntax colours.
```python
for item in packing_list:
print(item)
```
A Copy Code button beside the block copies its contents without the backticks. The backtick lines stay hidden unless the cursor is in the block.
Two languages are special: calc turns the block into a calculator (see Your first calculation), and mermaid draws a diagram, as below.
Formulas
Write mathematics in TeX notation. Wrap it in single dollar signs to keep it within a sentence (Format › Math Formula), or put it between double dollar signs on their own lines to show it as a block (Format › Math Block):
The area of a circle is $\pi r^2$.
$$
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
$$
With the cursor in a formula, you see its source with a live preview as you type. Varlig supports common TeX commands; a command it doesn’t know shows an error in place of the formula.
A formula shows the maths. To work out an answer, use a calc block instead.
Mermaid diagrams
Describe a flowchart, timeline or another diagram in text and Varlig draws it in the note. Choose Format › Mermaid Diagram to insert a starter, or write a mermaid block:
```mermaid
flowchart LR
Idea --> Plan --> Done
```
The first line names the kind of diagram. Varlig draws flowcharts (flowchart or graph), sequenceDiagram, classDiagram, stateDiagram, erDiagram, pie, gantt, journey, timeline, mindmap, gitGraph, quadrantChart, xychart, sankey, kanban and more. Edit the text and the diagram follows.
A diagram can have up to 512 lines, 256 boxes and 512 connections.
YAML front matter
Some tools read metadata from the top of a Markdown file. Choose Format › YAML Front Matter to add a block between two --- lines at the very start of the note:
---
project: Kitchen
status: planning
---
Varlig keeps front matter exactly as you write it, and uses the first line after it as the note’s title.
HTML
Varlig shows HTML tags as text rather than turning them into formatting. The one exception is <br>, which starts a new line.