nx_md_render.nx
buildroot/runtime/nx_md_render.nx
about
nx_md_render.nx -- sovereign Markdown -> HTML renderer.
Single-pass. Scan input bytes line-by-line; emit HTML bytes.
CommonMark subset suitable for andelinwest.com and similar
human-written content:
# Heading -> <h1>Heading</h1>
## Heading 2 -> <h2>Heading 2</h2> ... up to ######
normal paragraph -> <p>normal paragraph</p>
- list item -> <ul><li>list item</li>...</ul>
*italic* -> <em>italic</em>
**bold** -> <strong>bold</strong>
`code` -> <code>code</code>
[text](url) -> <a href="url">text</a>
--- -> <hr />
blank line -> closes the current paragraph or list
``` -> toggle pre-formatted code block
Not yet supported (named improvement, queued L10b):
tables, blockquotes, ordered lists, nested lists, images, footnotes,
reference links, HTML pass-through. These mostly compose by adding
one more transition state to the scanner; the substrate stays the
same shape.
Escaping: <, >, &, " in input bytes are emitted as < > &
" in output (skipping HTML pass-through for safety).
genealogy_id: commonmark_0_30 + cmark_2014 + markdown_perl_2004
lineage_id: nishi_markdown_subset_q10
dependencies 1 imports · 1 importers
imports: nx_syscalls.nx
imported by: nx_build_site.nx
structs
| none |
consts
| 217 | const NX_MD_STATE_NONE: i64 = 0 |
| 218 | const NX_MD_STATE_PARA: i64 = 1 |
| 219 | const NX_MD_STATE_LIST: i64 = 2 |
| 220 | const NX_MD_STATE_CODE: i64 = 3 |
functions
| 43 | func _emit1(out: *u8, off: i64, b: i64) -> i64 called by 1: nx_md_render |
| 49 | func _emitn(out: *u8, off: i64, src: *u8, n: i64) -> i64 |
| 58 | func _emit_esc1(out: *u8, off: i64, b: i64) -> i64 |
| 81 | func _emit_inline(out: *u8, off_in: i64, src: *u8, n: i64) -> i64 |
| 223 | func _close_block(out: *u8, off_in: i64, state: i64) -> i64 called by 1: nx_md_render |
| 244 | func nx_md_render(src: *u8, n: i64, out: *u8) -> i64 |