Clew Manual

Writing

Converting colon directives

jmarkdown is retiring its colon directives — :::name … ::: blocks, ::name[…] and :name[…] — in favour of the @ forms that do the same jobs: @begin(name) … @end(name), @name+[…] and @name[…]. Clew itself writes only the @ forms (the Format menu); Convert Colon Directives… rewrites the ones a vault already holds. It is never automatic. It shows you what it would do before it does anything, leaves whatever would look different for you to choose, copies every note before changing it, and can be undone. The colon forms still work today. (Not in 0.12.0.)

A dry run first

Choose File → Convert Colon Directives…, or Convert colon directives in this vault… in the command palette (⌘P). Clew saves any unsaved edits, then reads every note in the vault (.md and .jmd) and works out what converting it would do. Nothing is written: the sheet that opens says how many notes it looked at, how many use colon directives, and Nothing has been changed yet. A vault with none says nothing to convert and offers only Done.

Each directive becomes the @ form that does the same job:

WrittenConverted
:today, :span[this part]{.hl} @today, @span[this part]{.hl}
::title[A title] @title+[A title]
:::TeX … ::: @begin(TeX) … @end(TeX)
:::note … ::: @begin(<note>) … @end(note)

A name with no meaning of its own, like note, is drawn by the colon form as an element of that name, <note>; the angle brackets in @begin(<note>) keep it one. Only directives are touched. Code, maths, the metadata header, comments and the bodies of TeX, TiKZ, mermaid and other verbatim blocks are left alone, and so is a colon in ordinary text that merely looks like one: a Meta Bind field such as INPUT[toggle:done] is never listed. A directive once converted is never offered again.

The sheet

The sheet sorts what it found into groups, each listing its notes. Open a note to see its lines: each gives the line number, what is written and, where it can convert, what it would become.

Same output
Directives that render exactly as before once converted, counted. These are converted; there is nothing to tick.
Output changes
Directives that would render differently once converted (see below). Each is a row of its own, unticked, with a Convert box, the @ form it would get, and why its output changes; all of these ticks the group. A row left unticked stays exactly as written.
Notes that load directives
Notes that bring colon directives of their own, where nothing is converted unless you tick it — Convert anyway on each row (see below).
Left as written
What the converter cannot write faithfully, each with its reason and no box: a block with two names on its opening line, a ::: with no name, a block that is never closed, or a directive glued to the word before it (word:span[…]), where an @ would not be read as a directive. Change these by hand if you want the @ form.
Notes not converted
Notes refused by name: one that is not UTF-8 text, since writing it back would change its bytes, and one whose lines end both ways (CRLF and LF), since converting it would change every line ending. A note whose lines all end in CRLF is converted and keeps them.

The button says what will happen. With nothing ticked it reads Convert all but the output changes (9): the Same output directives are converted, and every row you have not ticked stays as it is. Tick rows and it counts them in — Convert 10 directives. Cancel, or Esc, closes the sheet having written nothing. The sheet opens with the focus on itself, not on Convert.

The output changes

Most names render the same in either spelling. Some do not, because the colon form never knew them, and converting one changes what you see:

Each row's reason says which applies. These are the differences What gets a number describes: only the @begin(…) forms are numbered.

Same output means the same reading view and HTML. A LaTeX export can still differ. The colon form wrote a generic block into the .tex as its HTML tags, <note> … </note>, and :span[…] as a <span>. Converted, the block is \begin{note} … \end{note}, which does nothing until the document defines it, and the span is just its text. A :::TeX block glued the next paragraph's first word straight onto its last line (only}.A description); after @begin(TeX) there is a line break, which LaTeX reads as a space, but the text after it still continues the same paragraph. To start a new one, end the TeX body with \par.

Notes that load directives

A note can bring colon directives of its own: through its header's Load directives, or through a Directives or Optionals list in a .jmarkdown/config.json — in the note's folder or any folder above it up to the vault's root, or your global ~/.jmarkdown/config.json (see Exports use your jmarkdown configuration). A loaded directive may define any name, so in such a note Clew assumes nothing and converts nothing by itself. If your global configuration loads directives, every note in the vault is in this group.

Each row says what loads them, and which name is in doubt: Loads/Folder/.jmarkdown/config.json loads directives (Directives); one may define note. Convert anyway converts that line as it would be in a note that loads nothing. A name the note's own header loads, such as a :::callout under Load directives: callout from my.js, has no box: the converter cannot port it, and says to move it to Load environments first.

What keeps your notes safe

The copies are kept in a colon-conversion folder:

PlatformWhere the copies are kept
macOS ~/Library/Application Support/Clew/colon-conversion/
Windows %APPDATA%\Clew\colon-conversion\
Linux ~/.config/Clew/colon-conversion/

Inside it each vault has a folder, named for the vault and a short hash of where it is, holding one folder per conversion, named for its moment: notes/, the notes as they were, laid out as in the vault, and the manifest.json that Undo reads.

Undo

The result offers Undo at once. Later, File → Undo Colon Conversion…, or Undo the last colon conversion… in the palette, asks first: Put back the 3 notes converted on …? A note changed since then is left as it is.

Undo puts back, byte for byte, every note that is still exactly as the conversion wrote it, keeping the converted text in the note's history first. A note you have changed since is left as you made it, and named, with the folder that holds its copy from before. Each Undo takes back the newest conversion not yet undone; when there is none, Clew says This vault has no colon conversion to undo.

Reference

FactDetail
Convert File → Convert Colon Directives…; Convert colon directives in this vault… in the palette. No default hotkey.
Undo The result's Undo; File → Undo Colon Conversion…; Undo the last colon conversion… in the palette.
Notes read Every .md and .jmd note in the vault; a dry run, which writes nothing.
Converted unless you cancel Same output: directives that render as before.
Converted if you tick them Output changes (Convert); rows in notes that load directives (Convert anyway).
Never converted Left as written, each with its reason; notes that are not UTF-8, or whose lines end both ways.
Before a note is written Checked against the dry run (changed: not written, offered again); copied to colon-conversion/ in Clew's data on this device; kept in its history.
Notes open in an editor Changed in the editor and saved; ⌘Z takes it back.
Undo puts back Only notes still exactly as converted; the rest are named.
Restricted vaults Offered; nothing of the vault's runs.

See also