TheBrain Markdown Reference

Markdown starts with plain text and allows document formatting with easy-to-type markup. It is a popular format for writing on the web and is widely supported across applications.

Notes are written in a rich text editor, so you work with the formatting itself and the Markdown stays out of your way. When you would rather work with the markup, switch the note to Text view to edit the Markdown directly, or Split view to edit it with the formatted note alongside.

Starting with TheBrain 15.0.610, notes are saved as standard Markdown: GitHub Flavored Markdown plus the notetaking extensions described below. A note saved this way opens and edits correctly in other Markdown tools. New brains use it from the start, and an existing brain can be switched to it in Brain Settings > Content Settings.

Earlier versions of TheBrain wrote notes in TheBrain’s own Markdown dialect. That dialect is deprecated, and a future release will stop writing it entirely — notes already written in it stay readable. Turn on the Legacy switch below for its reference.

Markdown Visibility

Markdown formatting tags are generally hidden when you are interacting with the document in TheBrain. To see and edit them, switch the note to Text view, which shows the markup on its own, or Split view, which shows the markup and the formatted note side by side and keeps them in step as you type. The same markup is what the note’s Notes.md file contains, so editing that file in another editor works too.

You can also copy text as raw markdown to paste into other applications that use it. If you paste raw markdown into TheBrain, it will be interpreted and formatted accordingly.

For convenience the following markdown can be typed directly into the editor starting with TheBrain 15:

  • Headings
  • Unordered lists
  • Ordered lists
  • Checkboxes (checked and unchecked)
  • Horizontal rules
  • Blockquotes
  • Math expressions
  • Inline code
  • Highlights
LegacyTurn on for TheBrain Markdown, applicable only to versions prior to 15.0.610.

Standard Markdown

TheBrain reads and writes GitHub Flavored Markdown:

First line
Another line
 
A new paragraph.
First line
Another line
 
A new paragraph.

Every line break you type is kept as a line break, and a blank line stays blank. This matches how notetaking applications normally behave; a strict Markdown viewer such as GitHub’s file preview will run the lines of a paragraph together.

# Title
TitleDifferent levels of headings can be achieved by varying the number of # characters at the start of a line from 1 to 6.
## Subtitle
SubtitleSlightly smaller than a Title.
### Heading
HeadingSlightly smaller than a Subtitle.
#### Sub-heading
SubheadingSmaller than a Heading.
> A blockquote
Start a line with > to get
A blockquote
*Italic* emphasis
Italic emphasis
**Bold** emphasis
Bold emphasis
The game is ~~almost~~ over
The game is almost over.

Surround the text with a pair of ~~ tags.

Inline `code` style
Inline code style (monospaced formatting)
```python
print("Code block")
```
print("Code block")

Code blocks are monospaced and ignore Markdown formatting within them. The word after the opening fence names the language for syntax highlighting and is optional.

- A bullet list
- Unordered items
  • A bullet list
  • Unordered items
1. Numbered list
2. Ordered items
  1. Numbered list
  2. Ordered items
- [x] Done (checked)
- [ ] To do (unchecked)
  • Done (checked)
  • To do (unchecked)
[a link](https://en.wikipedia.org/wiki/URL)
This is a link to a Wikipedia page.

Links to thoughts (Local Thought URLs) are done in the same manner, with a brain: link: [A thought](brain://...)
![alt text|50%](https://en.wikipedia.org/wiki/Image)
Example embedded image
In the desktop and mobile clients, add images using copy-and-paste or drag-and-drop. Images can be resized from full width (100%) down to 5%, written as a percentage after the alt text: ![alt text|50%](...). Pixel sizes written by other applications (|300, |300x200) are preserved as they are.
Horizontal rule

***

Between paragraphs

Horizontal rule


Between paragraphs

TheBrain writes *** because a line of --- can be mistaken for note properties or for an underlined heading. --- and ___ are read as horizontal rules too.

\* Escaped text
* Escaped text

Use \ to escape single characters that would otherwise be interpreted as markdown formatting commands. In this example, the line would be a bulleted list if the backslash were not present.

Notetaking Extensions

A handful of formatting features have no syntax in Markdown itself, but notetaking applications have settled on a common way of writing them. TheBrain uses that same syntax, so these read correctly in applications such as Obsidian, Joplin and Typora — and, in the case of callouts, on GitHub as well.

==Highlighted== text
Highlighted text
> [!NOTE]
> Worth knowing.
Note
Worth knowing.

A callout is a blockquote whose first line names a type. There are thirteen — NOTE, ABSTRACT, INFO, TODO, TIP, SUCCESS, QUESTION, WARNING, FAILURE, DANGER, BUG, EXAMPLE and QUOTE — and the aliases other applications use are understood too, so IMPORTANT reads as a tip and CAUTION as a warning.

Add text after the type to give the callout its own title, or a + / - after the closing bracket to make it foldable.

Inline $e = mc^2$ math
 
$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$
LaTeX rendered example

Enclose a LaTeX expression in single $ tags for math within a line of text, or in $$ tags for a formula on a line of its own. Write a literal dollar sign as \$.

Provides support for: Simple algebraic equations, Fractions and continued fractions, Exponents and subscripts, Trigonometric formulae, Square roots and n-th roots, Calculus symbols (limits, derivatives, integrals), Big operators (e.g. product, sum), Big delimiters (using \left and \right), Greek alphabet, and much more...

A claim.[^1]
 
[^1]: The supporting detail.
A claim.1

[^1] in the text is a footnote mark; a line beginning [^1]: is the note itself. TheBrain shows the mark as a superscript and keeps the notes at the foot of the page.

A label does not have to be a number. Insert > Footnote leaves the number selected so you can type over it with anything you like — [^method] or [^Klein 1978] instead of [^3] — and the mark and its note are held together by that shared label. Renumbering the footnotes (right-click a mark) turns every label back into a number, so it will replace labels you typed yourself.

HTML for What Markdown Lacks

Markdown allows HTML tags to be mixed into the text, which is how underline, superscript and colored text are conventionally written. TheBrain writes the small set of tags below and reads them back into the editor. Other Markdown applications render them; note that GitHub removes style attributes, so colors appear as plain text there.

<u>Underlined</u> text
Underlined text
10<sup>2</sup> = 100
102 = 100
H<sub>2</sub>O is water
H2O is water.
<span style="background-color:#ffff00;
color:#aa0000">Red on yellow</span>
Red on yellow

Text and background colors are written as a CSS style attribute on a <span>. Colors are ordinary CSS hex values — #RRGGBB, or #RRGGBBAA when the color is partly transparent. Markdown still works inside the span.

<span style="font-family:Lobster">
Text in a special font</span>
Text in a special font

A single span carries any mix of color, background-color, font-family and font-size. Font sizes are read from notes written elsewhere; there is no UI for setting one at this time.

<div style="page-break-after: always;"></div>
Forces a page break when the note is printed or exported to PDF.

TheBrain Comment Tags

Some of what TheBrain stores has no equivalent anywhere in Markdown — line alignment, a generated table of contents, and the styling of a table (shown under Tables below). These ride in HTML comments, which every Markdown application preserves and none displays. Editing a note elsewhere leaves them intact, and TheBrain reads them back.

They all take one shape — <!--tb:KIND key:value;key:value--> — a kind, then a list of properties. That list is not merely shaped like a CSS style attribute; it is one, so you can hand it to whatever CSS declaration parser your language already has. A value is a bare token run, or a quoted string when it needs to hold a ;, a " or a space, and a backslash escapes the character after it. Kinds and property names you do not recognize can be ignored. The table-of-contents markers below are the one exception, because they are the ones the markdown-toc tool already uses.

Two details are worth knowing if you write a parser. A hyphen that follows another hyphen is written \-, because an HTML comment ends at the first --> and that happens before anything reads the CSS — the escape is itself valid CSS, so nothing is lost. And property names avoid any CSS property that means something else: table column widths are col-widths, never column-width, which in CSS is the width of a column of text in a multi-column layout. Where a name does match CSS, so does its meaning — background-color is a color, and colors are written the way CSS writes them.

Why comments and not HTML? Everywhere else on this page, what Markdown cannot express is written as HTML — <u>, <sup>, a styled <span> — because those tags render in other applications, so using them costs nothing and gains you the formatting wherever the note goes. These three cannot be written that way without giving something up. Wrapping a paragraph in a <div style="text-align:center"> would stop the Markdown inside it from being read as Markdown at all — bold, links and lists within the wrapper would go back to being literal text — and it would not even center anything on GitHub, which strips style attributes. Writing every styled table as an HTML <table> would show its colors, but at the cost of the pipe table, which is the form you can actually read and edit by hand in another editor.

A comment gives up neither. It is invisible in every Markdown application, so nothing appears that should not, and it is preserved by every one of them, so nothing is lost when the note travels and comes back. What it costs is that other applications do not act on it: a centered line shows up left-aligned elsewhere, and a table’s colors and column widths are TheBrain’s alone. That is the trade — the formatting is dormant rather than destroyed.

<!--tb:block align:center-->
Centered
Centered

The comment goes on its own line before the line it aligns, and applies to that line alone. center, right and justify are written; left alignment is the default and writes nothing. Other applications show the text unaligned.

<!-- toc -->
- [Installation](#installation)
- [Options](#options)
<!-- tocstop -->
A table of contents is written out as a real list of links between these two markers, regenerated from the note’s headings each time it is saved. The markers are the ones the widely used markdown-toc tool uses, so other tooling recognizes the block.

Tables

Tables are GitHub Flavored Markdown pipe tables, with column widths and colors carried in a comment before the table — and cells that can hold the full formatting of a note, which few other applications offer.

|Planet|Namesake|
|---|---|
|Mercury|Roman god of speed|
|Venus|Roman god of love|
|Earth|Variation of "the ground" in many languages|
|Mars|Roman god of war|
PlanetNamesake
MercuryRoman god of speed
VenusRoman god of love
EarthVariation of "the ground" in many languages
MarsRoman god of war
  • Each line of a table starts and ends with |
  • The first line is the header row, and a separator line of |---|---| follows it
  • Column alignment is set with colons in the separator line: |:---| left, |:---:| centered, |---:| right
  • A blank line follows the table
<!--tb:table col-widths:-1,110;background-color:#282c34;line-color:#454c5a-->
|Item|Description|Price|
|---|---|---:|
|Phone|Includes:<br>bright screen|1,000.00|
|Case|Shock resistant hard shell|19.00|
ItemDescriptionPrice
PhoneIncludes:
bright screen
1,000.00
CaseShock resistant hard shell19.00
  • A cell holding several lines of plain text joins them with <br>
  • Column widths, table colors and row colors are written in a <!--tb:table ...--> comment above the table, along with the alignment of the table as a whole (align:center) — one comment carries all of it
  • The comment may be separated from its table by blank lines; a comment with no table under it is dropped when the note is next saved
  • Attributes such as foreground-color:#ffe050 are separated by semicolons, and colors are ordinary CSS hex — #RRGGBB, or #RRGGBBAA when not fully opaque
  • Column widths use col-widths — not column-width, which is a real CSS property meaning something else entirely. Values are in pixels and begin sequentially at the first column; -1 represents a column that has no value assigned.
  • A table with no comment above it simply uses the default styling

Fully Formatted Table Cells

A cell in TheBrain is not limited to a line of text. It holds anything a note holds — several paragraphs, headings, bulleted and numbered lists, checkboxes, quotes, code blocks, images and math — with each line formatted on its own. Build a comparison table with a heading and a feature list in every cell, or a project table whose cells carry live checklists. Markdown’s own table syntax cannot express any of this, and most Markdown editors cannot either.

<table>
<thead><tr><th>Item</th><th>Description</th></tr></thead>
<tbody>
<tr><td><p>Phone</p></td>
<td><h4>Includes</h4>
<ul><li>Holographic display</li><li>Telepathic UI</li></ul></td></tr>
</tbody>
</table>
ItemDescription
Phone
Includes
  • Holographic display
  • Telepathic UI

TheBrain writes these tables out as HTML <table> tags, so the headings, lists and checkboxes inside the cells stay visible when the note is opened in another Markdown application, on GitHub, or in a browser. Editing that structure is another matter: formatting inside a table cell is unique to TheBrain, so other applications will generally show such a table without letting you work on the content of its cells. Come back to TheBrain and it is a live, editable table again.

Note Properties

Some applications keep a note’s properties — tags, aliases, dates — in a block of YAML between two lines of --- at the very top of the file, also called frontmatter. TheBrain leaves that block exactly as it finds it: it is never displayed in the editor, never edited, and never removed, so properties you set in another application survive editing the note in TheBrain.