std.mym, the standard def-sheet
The standard def-sheet for MyMark. Only the definition lines are read; the rest of this file is commentary, for a reader. The functions named here are in std_html.py.
Blocks
Block definitions, written as a sample line with ... for the text. One space before ... allows any space; two require wide space. With no ... the label stands alone on its line. A label is matched as written, or by example: ? after the symbols stands for any word, which becomes the block's id, so ##? is for ##intro, and ```? for ```python; ... in a label stands for any text, as in [^...]:. Nothing else is tried, so -5 °C at the start of a line is prose.
# ... => heading 1
## ... => heading 2
### ... => heading 3
#### ... => heading 4
##### ... => heading 5
###### ... => heading 6
#? ... => heading 1
##? ... => heading 2
###? ... => heading 3
####? ... => heading 4
#####? ... => heading 5
######? ... => heading 6
> ... => quote
- ... => bullet tasks
List: => listblock
Tree: ... => tree
+ ... => numbered
1. ... => numbered
2. ... => numbered
3. ... => numbered
4. ... => numbered
5. ... => numbered
6. ... => numbered
7. ... => numbered
8. ... => numbered
9. ... => numbered
--- => rule
[TOC] => contents 2 3
[^...]: ... => footnote
``` ... => codeblock
```? ... => codeblock
```demo => demo
| ... => line table
A line [TOC] is a table of contents: links to the document's headings, levels 2 and 3, nested. Every heading has an id for it, the word given, as in ##intro, or else one made from its text, as GitHub makes them. GitLab's Markdown reads [TOC] the same way. Other levels are one more definition: [TOC] => contents 2 4.
The bar and the fold are boot's (boot.mym): the bar is a line of the content of the block above, the fold carries on the line before it. What a bar line means is for the block to say. In prose it keeps the line break; in code it is a line as written; in a callout it is a line of a MyMark document of its own, so | lines may hold any blocks, | lines too. A fence is a definition too: ```, and ```? and ```demo, gather every line up to a closing ``` line, and those lines are never read as labels or definitions. With no closing line, a ``` line holds its | lines as code instead. A ```demo fence shows its MyMark source, then its translation; definitions inside it stay in it.
std redefines the bar, | ... => line table, for one case: a block of bar lines with no block above it is a table, if it is one; line table says try the table function first. A pipe table is GitHub's: a header row, a row of dashes, with colons to align, then the rows. A bar inside a bag or an element does not split a cell, so `a|b` needs no escape.
Callouts
Lists have a formal block, List:, standing alone, its items as its bar lines: the everyday list is the same with the label left out. Two lists in a row are written with it, since a list carries on across blank lines. Tree diagrams are Tree: blocks: the root after the label and the tree in its bar lines, or the whole tree in its bar lines; read by the tree-line grammar, treeline.peg, tall or fat, and drawn tall.
Callouts, or admonitions: a box set off from the text, with a coloured bar, a light background and an icon. The ! sigil says pay attention. The callout function takes the kind, which the style sheet colours, and the icon. Each label is a box of its own, and its | lines are what it holds. Any kind may be added, with a word of its own: !idea ... => callout idea 🌱.
!tip ... => callout tip 💡
!info ... => callout info ℹ️
!warning ... => callout warning ⚠️
A plain word can be a label too, when the text after it is set off by wide space, which prose rarely has: Note: followed by one space is prose.
Note: ... => callout note 📝
Divisions
Divisions with a class, for a style sheet: the generic block, as span is the generic element. Each name is defined, so nothing else is caught: .aside ... => div gives a division of class aside, and its | lines are what it holds. A class other than the name may be given: .wide ... => div full-width.
Metadata and sheets
Metadata: a name with a colon, then wide space, so a line of prose that starts title: is still prose. Usually at the top of the document; it shows nothing there. It counts only at the top level: in a demo or | lines it is prose. The title is the page's title; without one, the first level 1 heading is. Any other name of your own may be added in the same way: keywords: ... => meta keywords.
title: ... => meta title
author: ... => meta author
date: ... => meta date
Def-sheets of a document's own are named with sheets: my.mym, and a def-sheet read as a document shows its definitions with definitions: shown, as this one does: both are boot's (boot.mym). Box diagrams, after Rick Workman's abc, and his array tables have a sheet of their own: sheets: abc.mym.
Inline elements
Inline definitions are patterns, written by example with ... for the content. Every pattern is MyMark's: some are its own forms, and some mimic Markdown. Run python3 mym.py --grammar to see the grammar they compile to.
MyMark's own elements: a sigil and a bag. A definition with no tag is for elements with no tag; ? stands for any tag, and a tag that the definition does not name becomes a class, as in *red(warning).
*(...) -> emphasis
*?(...) -> emphasis
**(...) -> strong
**?(...) -> strong
`(...) -> code
`?(...) -> code
_(...) -> sub
,(...) -> sub
^(...) -> sup
$(...) -> math
Links
An address is given by defining a label, as in @[label] -> link https://example.org, or else the content is the address.
@(...) -> link
Named tags
Named tags, with the dot. The mid-dot is another way to write the dot, so each of these may also be written ·mark‹text›, which never collides with English text. A name with no definition is left as written. With no name, the dot gives its content as plain text, not read as markup: .(*not emphasis*).
.(...) -> plain
.em(...) -> emphasis
.strong(...) -> strong
.code(...) -> code
.sub(...) -> sub
.sup(...) -> sup
.mark(...) -> mark
.link(...) -> link
.math(...) -> math
Spans
Spans with a class, for a style sheet: the generic element. Each name is defined, so that list.append(x) stays as written: .warn(...) -> span gives a span of class warn, and .key(...) -> span kbd a span of class kbd.
Macros
A notation made of others, in MyMark itself, with no code: the function mym, with MyMark as its arguments and ... for the content, as in .warn(...) -> mym **red(...). For a block, mymblock, with ... for the text after the label; the block's own lines follow it, so | lines stay | lines: Todo: ... => mymblock !warning To do: .... The guide, notations.mym, has more, and functions of your own.
Quoted bags
A bag between a sigil and the same sigil again. They read the same in MyMark, and nearly so as Markdown. The bag holds anything, so *(**bold** italic)* needs no ***, and `( a`b )` is code with its backtick and spaces, with no counting.
*(...)* -> emphasis
**(...)** -> strong
`(...)` -> code
~~(...)~~ -> strike
Markdown's forms
Mimicked by patterns. A quote's content does not start or end with space, so 2 * 3 * 4 is arithmetic. A line [label]: address defines label and ![label]; a line [^1]: the note is a footnote, and ^1 refers to it.
*...* -> emphasis
**...** -> strong
`...` -> code
~~...~~ -> strike
[...] -> link
[^...] -> noteref
[...](...) -> link
 -> image
<...> -> url
Glyphs
Glyphs, named by their content. A name may also be written after the ~ with no bag, as ~c or ~smile: a sigil and a tag, which must start a word. A word after the glyph is a class for a style sheet, as in ~(->) -> glyph → arrow.
~c -> glyph ©
~tm -> glyph ™
~smile -> glyph 🙂
~sad -> glyph 🙁
~(->) -> glyph →
~(<-) -> glyph ←
~(=>) -> glyph ⇒
~(--) -> glyph –
~(---) -> glyph —
~(c) -> glyph ©
~(tm) -> glyph ™
~(smile) -> glyph 🙂
~(sad) -> glyph 🙁