nx_markdown_block.nx
buildroot/runtime/nx_markdown_block.nx
about
markdown_block.nx -- block-level Markdown -> HTML.
CommonMark §4 + §5 practical subset. Walks input line-by-line
recognising block constructs, sends runs of text through
markdown_inline for inline formatting.
Supported block-level constructs:
# Heading -> <h1>...</h1> (levels 1-6 by # count)
## Subheading -> <h2>...</h2>
(blank line) -> closes current paragraph
```fenced -> <pre><code>...</code></pre>
- bullet -> <ul><li>...</li></ul>
* bullet -> <ul><li>...</li></ul>
1. ordered -> <ol><li>...</li></ol>
regular text -> <p>...</p>
NOT supported (future markdown_block_ext.nx): tables, blockquotes,
setext headings (=== / ---), horizontal rules, link reference
definitions, indented code blocks.
Composes markdown_inline + html_escape.
Invariants:
B1 Fenced code block content is NOT run through inline
markdown -- raw text with html_escape only.
B2 List items have inline markdown applied to their content.
B3 Consecutive list items collapse into one <ul> / <ol>.
B4 Output is valid HTML fragment (no <html>/<head>/<body>).
nx_safety_envelope:
intended_use: "Markdown block-level parser (CommonMark
section 4) -- docs / README / nishi-library
catalog ingestion"
sil_target: SIL1
asil_target: QM
dal_target: NONE
evidence: [CommonMark_0_30_canonical_basis,
sealed_block_kind_enum, no_FP,
bounded_block_parse_state_machine]
hazard_register: [bug-tape-XSS-via-raw-HTML-passthrough,
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_markdown_inline.nxnx_html_escape.nx
imported by: markdown_block.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 49 | const MB_MAGIC_2048: i64 = 2048 |
| 51 | const MB_ERR_SHORT: i64 = -1 |
functions
| 53 | func mb_put(out: *u8, cap: i64, off: i64, src: *u8, n: i64) -> i64 {
called by 1: markdown_block |
| 64 | func mb_put_inline(out: *u8, cap: i64, off: i64, |
| 72 | func mb_put_esc(out: *u8, cap: i64, off: i64, |
| 80 | func mb_eol(buf: *u8, n: i64, off: i64) -> i64 {
called by 1: markdown_block |
| 90 | func mb_heading_level(buf: *u8, off: i64, eol: i64) -> i64 {
called by 1: markdown_block |
| 107 | func mb_is_fence(buf: *u8, off: i64, eol: i64) -> i64 {
called by 1: markdown_block |
| 118 | func mb_is_bullet(buf: *u8, off: i64, eol: i64) -> i64 {
called by 1: markdown_block |
| 130 | func mb_is_ordered(buf: *u8, off: i64, eol: i64) -> i64 {
called by 1: markdown_block |
| 150 | func mb_is_blank(buf: *u8, off: i64, eol: i64) -> i64 {
called by 1: markdown_block |
| 163 | func markdown_block(src: *u8, n: i64, out: *u8, cap: i64) -> i64 {
called by 2: mainnx_wiki_doc_render calls 9: mb_eolmb_is_blankmb_putmb_is_fencemb_put_escmb_heading_level+3 |
| 318 | func main() -> i64 { |