AtlatestRepositorysigil-markdown
1# sigil-markdown
2
3A CommonMark-style Markdown parser for [Sigil](https://codeberg.org/sigil/sigil) with YAML front matter support. Produces SXML output for use with `(sigil sxml)`.
4
5## Features
6
7- CommonMark-style Markdown parsing
8- YAML front matter extraction
9- SXML AST output
10- PEG-based inline parsing
12### Supported syntax
14| Element | Syntax |
15|-----------------|-------------------------------------|
16| Headers | `# H1` through `###### H6` |
17| Paragraphs | Blank-line separated text |
18| Code blocks | Fenced (```) or indented (4 spaces) |
19| Blockquotes | `> quoted text` |
20| Unordered lists | `- item`, `* item`, `+ item` |
21| Ordered lists | `1. item`, `2. item` |
22| Horizontal rule | `---`, `***`, `___` |
23| Tables | `| col | col |` with separator |
24| Inline code | `` `code` `` |
25| Bold | `**bold**` or `__bold__` |
26| Italic | `*italic*` or `_italic_` |
27| Links | `[text](url)` |
28| Images | `![alt](src)` |
30## Usage
32```scheme
33(import (sigil markdown))
35;; Parse a Markdown string to SXML
36(markdown->sxml "# Hello\n\nWorld")
37;; => (document (h1 "Hello") (p "World"))
39;; Parse a Markdown file
40(markdown-file->sxml "README.md")
42;; Front matter is parsed into SXML attributes
43(markdown->sxml "---\ntitle: Hello\n---\n\n# Content")
44;; => (document (@ (title "Hello")) (h1 "Content"))
45```
47## API
49- `markdown->sxml` - Parse a Markdown string to SXML
50- `markdown-file->sxml` - Parse a Markdown file to SXML
51- `parse-front-matter` - Extract YAML front matter from text
52- `parse-blocks` - Lower-level block parser
53- `parse-inline` - Lower-level inline parser
55## Dependencies
57- [sigil-stdlib](https://codeberg.org/sigil/sigil) - Sigil standard library
58- [sigil-peg](https://codeberg.org/sigil/sigil-peg) - PEG parsing library
60## Development
62```sh
63sigil deps install
64sigil build
65sigil test
66```
68## License
70BSD-3-Clause