AtlatestRenderedmarkdown
Readme

sigil-markdown

A CommonMark-style Markdown parser for Sigil with YAML front matter support. Produces SXML output for use with (sigil sxml).

Features

  • CommonMark-style Markdown parsing
  • YAML front matter extraction
  • SXML AST output
  • PEG-based inline parsing

Supported syntax

ElementSyntax
Headers# H1 through ###### H6
ParagraphsBlank-line separated text
Code blocksFenced (```) or indented (4 spaces)
Blockquotes> quoted text
Unordered lists- item, * item, + item
Ordered lists1. item, 2. item
Horizontal rule---, ***, ___
Tables`colcol` with separator
Inline code` code `
Bold**bold** or __bold__
Italic*italic* or _italic_
Links[text](url)
Images![alt](src)

Usage

(import (sigil markdown))

;; Parse a Markdown string to SXML
(markdown->sxml "# Hello\n\nWorld")
;; => (document (h1 "Hello") (p "World"))

;; Parse a Markdown file
(markdown-file->sxml "README.md")

;; Front matter is parsed into SXML attributes
(markdown->sxml "---\ntitle: Hello\n---\n\n# Content")
;; => (document (@ (title "Hello")) (h1 "Content"))

API

  • markdown->sxml - Parse a Markdown string to SXML
  • markdown-file->sxml - Parse a Markdown file to SXML
  • parse-front-matter - Extract YAML front matter from text
  • parse-blocks - Lower-level block parser
  • parse-inline - Lower-level inline parser

Dependencies

Development

sigil deps install
sigil build
sigil test

License

BSD-3-Clause