AtlatestRepositorysigil-markdown
sigil-markdown / treeREADME.md
1
# sigil-markdown3
A CommonMark-style Markdown parser for [Sigil](https://codeberg.org/sigil/sigil) with YAML front matter support. Produces SXML output for use with `(sigil sxml)`.5
## Features7
- CommonMark-style Markdown parsing8
- YAML front matter extraction9
- SXML AST output10
- PEG-based inline parsing12
### Supported syntax14
| 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 | `` |30
## Usage32
```scheme33
(import (sigil markdown))35
;; Parse a Markdown string to SXML36
(markdown->sxml "# Hello\n\nWorld")37
;; => (document (h1 "Hello") (p "World"))39
;; Parse a Markdown file40
(markdown-file->sxml "README.md")42
;; Front matter is parsed into SXML attributes43
(markdown->sxml "---\ntitle: Hello\n---\n\n# Content")44
;; => (document (@ (title "Hello")) (h1 "Content"))45
```47
## API49
- `markdown->sxml` - Parse a Markdown string to SXML50
- `markdown-file->sxml` - Parse a Markdown file to SXML51
- `parse-front-matter` - Extract YAML front matter from text52
- `parse-blocks` - Lower-level block parser53
- `parse-inline` - Lower-level inline parser55
## Dependencies57
- [sigil-stdlib](https://codeberg.org/sigil/sigil) - Sigil standard library58
- [sigil-peg](https://codeberg.org/sigil/sigil-peg) - PEG parsing library60
## Development62
```sh63
sigil deps install64
sigil build65
sigil test66
```68
## License70
BSD-3-Clause