Skip to main content

Module markdown

Module markdown 

Source
Expand description

Markdown, as far as notes are written in it: what a note marks as bold, slanted, struck out or code, its headings, what it quotes, its lists, its tables, and the links it names by something other than their address.

A note is plain text, and most are only that. Some are written as Markdown, in whole or in a word, and nothing in a note says which. So there is no deciding whether a note is Markdown: each mark is taken for what it is where it could be nothing else, and left as written everywhere else. A note with none of them comes out as it went in, one run of text, the same to the letter.

flowchart TD
    note["What a note says"] --> lines["Line by line"]
    lines --> fence{"Between two fences?"}
    fence -->|"yes"| block["Code, as written"]
    fence -->|"no"| kind{"How the line starts"}
    kind -->|"# "| heading["A heading: bold, larger"]
    kind -->|"> "| quoted["Quoted: quiet, behind a bar"]
    kind -->|"- "| item["An item: behind a dot or a box"]
    kind -->|"--- alone"| rule["A rule"]
    kind -->|"cells, and --- under them"| table["A table"]
    kind -->|"anything else"| text["Text"]
    heading --> inline["Within the line"]
    quoted --> inline
    item --> inline
    text --> inline
    inline --> runs["Runs: text in one style, code, links, blocks"]
    table -->|"each cell"| inline
    block --> runs
    rule --> runs

What is taken for Markdown, and what is not:

WrittenShown asLeft as written when
*slanted*, _slanted_SlantedThe marks are inside a word (2*3*4, snake_case), have a space on their inside, are not closed on the line, have a \ before them, or have no letter or figure between them (*_*)
**bold**, __bold__, ***both***BoldLikewise (f**k)
~~struck~~Struck outLikewise; one ~ is never a mark
`code`, with any number of backticksCodeThe same number does not close it on the line, or the backticks are inside a word (dont`)
A fence of three backticks or tildes, alone at the start of a line, and what follows down to anotherA block of codeNo fence closes it
# Heading, with up to six #, or a line with === under itBold, and the first three levels largerThere is no space after the #: that is a hashtag
> quoted, >quotedQuiet, behind a barWhat follows the > with no space is not a letter (>_<, >100)
- item, * item, + item, set in or notThe item, behind a dotNo other item stands on the line before or after: that is a dash, a footnote, a signature
- [ ] to do, - [x] doneThe item, behind a box, ticked or not
1. itemAs written: it reads as what it is
---, *** or ___ alone on a lineA rule
A line of cells between |, and under it a line of --- between as manyA table, each column set left, right or in the middle as its :---, ---: or :---: saysThe line under it is no such line
[label](https://…)A link that reads as its labelThe address is not one for the web
![label](https://…)The picture or the video there, or a linkLikewise
<https://…>The link
<br>A line break
\*, and a \ before any other markThe mark, and no \It is a shrug (¯\_(ツ)_/¯): a \_ with no letter on either side

Not Markdown here, and left as written: a line with --- under it (it is a line and a rule, not a heading), code set in by four spaces (notes are set in for other reasons), links whose address is given elsewhere ([label][1]), footnotes, and HTML other than <br>, which is never taken for anything.

A line break is a line break: lines are not joined into paragraphs, as Markdown would have it, since a note’s lines are its author’s.

Web addresses are passed over whole: what is in one is not a mark. A mark at the very end of one can still close what was opened before it (*see https://example.com/a*).

Nothing here reads links, mentions or hashtags: that is content’s, which reads each run of text it is handed. What is code is not read for them at all.

Structs§

Inline 🔒
One line of a note, or a part of one, read for the marks in it.
Runs 🔒
The runs a note is made of, gathered: text of one style that follows text of the same is one run.
Style
How a run of text is set.
Table
A table: its columns, and its rows of as many cells each, the first of them the one that says what the columns are.

Enums§

Align
Where in its column a cell stands.
Block
What stands apart from a note’s text, with cells of Cell: of runs here, and of what content reads them into.
Run
A piece of a note, in reading order.

Constants§

AFTER_ADDRESS 🔒
The punctuation that follows a web address without being part of it.
CLOSING 🔒
The characters a mark may come straight before, a space apart: what closes a bracket or a quotation, or ends a clause, and a dash.
ITEM_DONE 🔒
ITEM_DOT 🔒
What stands before an item of a list, and before one that is to be done or is.
ITEM_TO_DO 🔒
LINK_PART_MAX_CHARS 🔒
How far a link’s label and its address are looked for the end of, in characters: longer than any is, and short enough that a note made of nothing but openings is read in the time any other is.
MAX_DEPTH 🔒
How deep marks inside marks are followed. Past this they are text: nobody writes them so, and a note is whatever its author sent.
OPENING 🔒
The characters a mark may come straight after, a space apart: what opens a bracket or a quotation, and a dash.
QUOTE_BAR 🔒
What stands before what a note quotes.
TABLE_MAX_CELLS 🔒
How many cells a table may have, all told. One of more is text.

Functions§

cells 🔒
The cells of a line of a table: what stands between its |, less the empty one before the first | and after the last. A | with a \ before it is no end of a cell, in code either, and is a | in it.
columns 🔒
Where each column stands, if line is the line under the first of a table: nothing but --- between |, with a : at the end the column is set towards, or at both for the middle.
fence 🔒
The character a fence is made of and how many of them, if line is one: three or more backticks or tildes at its start. opening, it may say after them what the code is written in, which a closing one doesn’t.
heading 🔒
How deep a heading is and what it says, if line is one: up to six #, a space, and something after it, less the # some close a heading with, a space after what it says.
is_mark 🔒
Whether c is one of the characters marks are made of: what a \ before it keeps from being one.
is_rule 🔒
Whether line is a rule: three or more of -, * or _, all the same, and nothing else but spaces.
item 🔒
The room before it and what it says, if line is written as an item of a list: a -, a * or a +, a space, and something after it.
line 🔒
One line of a note, outside any block, read into runs. listed, it is an item of a list if it is written as one.
of_a_word 🔒
Whether c is a letter or a figure of a word: one written with spaces between words.
quoted 🔒
What is quoted, if line quotes: after a >, or several, each with a space after it or not. With no space at all, only what starts with a letter is quoted: >_< is a face, and >100 a number.
runs
What content says, as runs: its text in the styles it marks, its code, the links it labels, and what stands apart from its text. Of a note that marks nothing, one run of text that is the note.
stress 🔒
What the mark of count times c adds to a style, if it is a mark.
table 🔒
The table that starts at the first of lines, if one does, and how many lines it is: a line of cells, the line that says where its columns stand, and every line of cells after that.
to_do 🔒
Whether it is done and what it is, if what an item says is something to do: [ ] or [x] before it.
underlines 🔒
Whether line is the line under a heading written as a line of text with === under it.
unpadded 🔒
Code as it was written between its backticks, less the one space at either end that sets it off from them, if there is one at both.
unspaced 🔒
Whether c is written without spaces between words, as Chinese, Japanese and Korean are: a mark beside one is not inside a word.