(samizdat markdown)

Reference

Overview

Markdown in a samizdat document: the commands markdown and include-markdown.

@markdown|{
## Why

Because *some* things are quicker to write this way.[^1] See |@ref["why"].

- [x] tables, task lists, ~~strikethrough~~ and footnotes, as GitHub has them

[^1]: And some are not.
}|

@include-markdown["post.md"]

(text markdown) reads the Markdown: CommonMark, with the extensions of GitHub Flavored Markdown. This module translates the result into the tree of samizdat. After the translation, no Markdown is left, and each converter sees the same tree as for samizdat markup:

The translation leaves out what samizdat does not have: the title of a link, and the number that an ordered list starts at.

The commands are in standard-commands.

See also: markdown, include-markdown, markdown->pieces

Reference

Functions

Functions

markdown

function ↑ Functions

(: markdown (-> Ctx Call (Vec Piece)))
(markdown cx c)

The command markdown: its body is Markdown, translated into the document.

cx
The state of the document.
c
The call.
returns
The blocks of the Markdown, as pieces.
@markdown|{
A paragraph with *emphasis*, and |@em{a command} in it.
}|

Write the body as |{...}| when the Markdown has braces or @ characters in it. {...} works too, when its braces balance.

A command works in the body: @em{x} in a {...} body, and |@em{x} in a |{...}| body. Each command is expanded where Markdown puts it. In text, it is what the command makes. In code, a link target or raw HTML, it is the text of what the command makes. A command that makes a block must be alone in a paragraph.

The command is rejected when it has an argument, a keyword or no body, and when a command that makes a block stands in running text.

See also: include-markdown, markdown->pieces

include-markdown

function ↑ Functions

(: include-markdown (-> Ctx Call (Vec Piece)))
(include-markdown cx c)

The command include-markdown: a Markdown file, translated into the document.

cx
The state of the document.
c
The call.
returns
The blocks of the Markdown, as pieces.
@include-markdown["notes/post.md"]

The argument is the path of the file. The path is relative to the file that the command is in. The file is added to the sources of the document. The file is read as it is: an @ in it is a character, not a command. YAML front matter at the start of the file is left out.

The command is rejected when it has a keyword or a body, when it has no path, and when the file does not exist.

See also: markdown, markdown->pieces

markdown->pieces

function ↑ Functions

(: markdown->pieces (-> Ctx Call string (Vec Piece)))
(markdown->pieces cx c text)

Markdown text as pieces of the document, for a command of your own.

cx
The state of the document.
c
The command that calls it. A rejection names this command.
text
The Markdown.
returns
The blocks of the Markdown, as pieces. The footnotes are added to the notes of the document.
;; @readme: the README.md of the project, as part of the document.
(: readme Command)
(defun (readme cx c)
  (markdown->pieces cx c (read-relative cx c "README.md")))

The text is Markdown only. An @ in it is a character.

See also: markdown, include-markdown