┌────────────────────────────┐ │Parsing Markdown with pulldown-cmark│ │ 2024-12-15 │ │ │ ├────────────────────────────┤ │ << Back to Blog │ └────────────────────────────┘
╔══════════════════════════════════════╗ ║ Parsing Markdown with pulldown-cmark ║ ║ 2024-12-15 ║ ║ ║ ╠══════════════════════════════════════╣ ║ << Back to Blog ║ ╚══════════════════════════════════════╝
╔══════════════════════════════════════════════════════════╗ ║ Parsing Markdown with pulldown-cmark ║ ║ 2024-12-15 ║ ║ ║ ╠══════════════════════════════════════════════════════════╣ ║ << Back to Blog ║ ╚══════════════════════════════════════════════════════════╝
╔══════════════════════════════════════════════════════════════════════════════╗ ║ Parsing Markdown with pulldown-cmark ║ ║ 2024-12-15 ║ ║ ║ ╠══════════════════════════════════════════════════════════════════════════════╣ ║ << Back to Blog ║ ╚══════════════════════════════════════════════════════════════════════════════╝
This blog uses pulldown-cmark for Markdown parsing and syntect for syntax highlighting.
The Pipeline
- Read
.mdfile fromposts/directory - Parse YAML frontmatter (title, date, slug)
- Convert Markdown to HTML
- Apply syntax highlighting to code blocks
- Store both HTML and plain text versions
Code
fn markdown_to_html(markdown: &str) -> String { let mut options = Options::empty(); options.insert(Options::ENABLE_STRIKETHROUGH); options.insert(Options::ENABLE_TABLES); options.insert(Options::ENABLE_FOOTNOTES); let parser = Parser::new_ext(markdown, options); // ... syntax highlighting logic }
Supported Features
- Bold and italic text
inline codeand fenced code blocks- Links
- Tables (as shown in other posts)
- Blockquotes
- Lists (ordered and unordered)
Strikethrough
Frontmatter Format
--- title: My Post Title date: 2024-12-15 slug: my-post-slug ---