Appearance
7. Inline Syntax
7.1 Catalogue
| Kind | Source example | AST node |
|---|---|---|
| Text | any unrecognized inline bytes | Text |
| Code span | `code` | Code |
| Emphasis | *em*, _em_ | Emphasis |
| Strong | **strong**, __strong__ | Strong |
| Strikethrough | ~~del~~ | Strikethrough |
| Link | [text](url "title") | Link |
| Image |  | Image |
| Autolink | <https://example.com>, <name@example.com> | Link |
| Hard break | two or more trailing spaces + LF, or \ + LF | LineBreak (hard: true) |
| Soft break | single LF within a paragraph | LineBreak (hard: false) |
| Custom inline | whitelisted md-* tag inline | CustomInline |
7.2 Parsing order within a block's inline content
Inline parsing MUST be left-to-right, single-pass, with a backtracking bound of one construct. The implementation attempts to match inline plugins in descending priority order (§9.3).
Core inline priorities:
- Code span: 210
- Link / image: 200
- Strong / emphasis / strikethrough: 200
- Custom inline: 50
- Autolink: 200
- Text: 1 (fallback)
7.3 Code span
A code span begins with a run of 1+ U+0060 (`) and ends at the next run of the same length. Content is verbatim, with a single leading and trailing U+0020 stripped if both present. No inline parsing occurs inside.
If no closing run of matching length exists by end-of-block, the opening run is literal and the run does not start a code span.
Cross-reference: CommonMark §6.1.
7.4 Emphasis & strong
MdFlow v1.0 uses a greedy-matcher algorithm (not CommonMark's delimiter stack), which differs in corner cases. The core rules:
**x**→Strong { children: inline(x) }*x*→Emphasis { children: inline(x) }__x__→Strong(if flanked per below)_x_→Emphasis(if flanked per below)***x***→Strong { Emphasis { inline(x) } }
Flanking rule: * never requires flanking; _ requires that the delimiter not be preceded/followed by an alphanumeric character on the inside (to avoid snake_case_identifier inside a word).
Unbalanced delimiters are literal. Nested emphasis parses innermost-first greedily.
Implementations' output for CommonMark emphasis corner cases MAY diverge from CommonMark; see Appendix B for the enumerated cases.
7.5 Strikethrough
~~text~~ → Strikethrough { children: inline(text) }. Requires two tildes on each side. Single tildes are literal.
Not in CommonMark core; origin: GFM §6.5.
7.6 Link
An inline link has the form:
[label](destination title?)label— any inline content;[and]inside must be escaped or balanced.destination— a URL. Parentheses inside the destination MUST be balanced or escaped, or the destination MAY be enclosed in<...>.title— OPTIONAL, in matching"...",'...', or(...)quotes, preceded by whitespace.
Destination MUST pass the URL filter of §10.3.1. A rejected URL becomes the empty string "".
Produces Link { url, title, children: inline(label) }.
Reference-style links ([label][id], [label][], [label]) are NOT supported in v1.0 (see Appendix B).
Cross-reference: CommonMark §6.3.
7.7 Image
An image has the form , with the same destination and title rules as links. alt is rendered as-text only; its inline constructs are parsed for accessibility-text purposes but not nested into image structure. Produces Image { url, alt, title }.
Destination MUST pass the image URL filter (§10.3.1).
Cross-reference: CommonMark §6.4.
7.8 Autolink
Two forms:
<absolute-uri>— whereabsolute-urimatches[a-z][a-z0-9+.-]*:[^\s<>]+. The scheme MUST pass the link URL filter.<email>— matching a simplified email regex; producesLinkwithmailto:prefix.
Cross-reference: CommonMark §6.5.
7.9 Line breaks
A hard break is produced by:
- Two or more U+0020 at end of a line followed by LF, OR
- A single U+005C (
\) at end of a line followed by LF.
A hard break in a Heading is NOT produced; the backslash or trailing spaces are literal within heading content.
A soft break is a single LF within a paragraph. Rendering: soft breaks MAY be rendered as U+0020 or U+000A at the implementation's discretion; the canonical form uses a single U+000A.
Produces LineBreak { hard: boolean }.
7.10 Escape
A \ followed by an ASCII punctuation character is a literal character with markdown significance removed. See §4.6.
7.11 Entities
MdFlow v1.0 recognizes a fixed, small set of HTML entities (informative list in Appendix D):
&,<,>,",', ,©,®,™,…,–,—.
Numeric entities ({, {) are NOT recognized (see Appendix B). All other &name; sequences are literal text.
7.12 Custom inline
A custom-inline tag (<md-tag attr="v">...</md-tag> or <md-tag/>) inside inline content is parsed per §8 and produces CustomInline or an event.
7.13 Ambiguity resolution
When two plugins of equal priority could match at the same position, the plugin registered earlier in the plugin list wins. See §9.3.
7.14 Text fallback
Any byte not consumed by a higher-priority inline plugin is appended to the current Text node. Consecutive unparsed bytes merge into a single Text node.