Skip to main content

Module markdown

Module markdown 

Source
Expand description

CommonMark syntax facts every Markdown writer in the family needs.

Each library renders its own document model, and how it styles a run is its own business. Where an emphasis delimiter may stand, and how text the document supplies — a picture’s description, a link’s target — has to be written so that it stays inside the construct it belongs to, are not: they are properties of CommonMark, and a writer that gets them wrong prints its syntax as text. This module answers those questions once so the writers cannot drift on them.

std-only, like the rest of the crate root.

Functions§

code_span
A code span holding text exactly as given: CommonMark reads it back as text, every line ending in it read as one space.
emphasis_can_pair
Whether the delimiter (* or _) characters of text can make emphasis among themselves: a run of them that can open (CommonMark §6.2: left-flanking, and for _ not inside a word) followed somewhere later by a run that can close.
emphasis_span
The part of a styled run that emphasis delimiters (*, **, ~~) can wrap, given the characters the run lands between, or None when no part can.
escape_block_starts
Whether the text after an & makes it a character reference (§6.2) — name;, #123; or #x1F; — which CommonMark would replace by the character it names. text with whatever would open a block at the start of one of its lines escaped, so that prose written into a paragraph or a list item reads back as that prose.
escape_html_syntax
text with what a Markdown reader would take for HTML escaped: a < that can open a tag, a comment, a declaration, a processing instruction or an autolink, and a & that starts a character reference.
image
A picture as an inline image: ![alt](destination).
link
An inline link: [label](destination), or [label](destination "title").
link_destination
A link or image destination, written so that CommonMark reads back exactly url (§6.3).