Lexical Grammar & Markdown to HTML AST Transformation Rules
Markdown processors evaluate recursive block and inline grammars to output structurally sound HTML5 elements:
1. Inline Grammar Token Mapping Functions
**T** ⟹ <strong>T</strong>
*T* ⟹ <em>T</em>
`C` ⟹ <code>C</code>
2. Block Heading & Link Mapping Invariants
#^k T ⟹ <h_k> T </h_k>, [L](U) ⟹ <a href="U"> L </a>
Step-by-Step Markdown Compilation Breakdown
Step 1: Block Level Lexing (Headings, Code Fences, Blockquotes)
Scan line starts for
#, >, ```, -, 1. markers.Step 2: Inline Token Replacement
Replace bold, italics, inline code, and hyperlink anchors.
Step 3: Paragraph Wrapping & List Aggregation
Output=Valid, Semantic HTML5 Hierarchy
Markdown vs HTML Syntax Reference
| Element | Markdown Syntax | HTML5 Tag | Display Result |
|---|---|---|---|
| Heading 1 | # Title | <h1>Title</h1> | Large Page Heading |
| Bold Text | **bold** | <strong>bold</strong> | bold |
| Hyperlink | [Label](url) | <a href="url">Label</a> | Clickable Link |
| Code Block | ```js ... ``` | <pre><code>...</code></pre> | Monospace Box |