nx_build_doc.nx
buildroot/runtime/nx_build_doc.nx
about
nx_build_doc.nx -- render a single .md document into final HTML.
The atomic build unit for nx_build_site (the bits-up replacement
for nishi-pages/build/build.py). Composes:
nx_frontmatter -- split "---YAML---body"
nx_yaml_subset -- parse the frontmatter YAML metadata
nx_md_render -- markdown body -> HTML
nx_http_template -- {{ var }} + {{ var | raw }} substitution
Pipeline for one .md doc:
1. Read source bytes
2. Split frontmatter -> (yaml_bytes, body_bytes)
3. Parse yaml metadata into NxYamlDoc (title, date, layout, etc.)
4. Render markdown body -> body_html
5. Apply inner template (post.html or page.html) substituting
page.title, page.date, page.author, body (raw)
6. Apply outer layout (layout.html) substituting site.*, page.*,
content (raw) where content = inner template output
7. Caller writes the final HTML wherever it wants
nx_safety_envelope:
intended_use: render one md doc end-to-end for nx_build_site
sil_target: SIL2
evidence: bench/nx_build_doc_smoke.nx round-trips a known
fixture and asserts the output bytes contain the
expected substituted values
verdict: NOT_YET_EVALUATED -- pending smoke
dependencies 4 imports · 1 importers
imports: nx_syscalls_x86_64.nxnx_yaml_subset.nxnx_frontmatter.nxnx_http_template.nx
imported by: nx_build_site.nx
structs
| 91 | struct NxBuildVars |
consts
| 37 | const NX_BUILD_DOC_OK: i64 = 0 |
| 38 | const NX_BUILD_DOC_BAD_INPUT: i64 = 1 |
| 39 | const NX_BUILD_DOC_FRONTMATTER_FAIL: i64 = 2 |
| 40 | const NX_BUILD_DOC_YAML_FAIL: i64 = 3 |
| 41 | const NX_BUILD_DOC_INNER_TMPL_FAIL: i64 = 4 |
| 42 | const NX_BUILD_DOC_OUTER_TMPL_FAIL: i64 = 5 |
| 43 | const NX_BUILD_DOC_OUT_TOO_SMALL: i64 = 6 |
| 44 | const NX_BUILD_DOC_VERDICT_N: i64 = 7 |
| 87 | const NX_BD_MAX_VARS: i64 = 16 |
| 88 | const NX_BD_NAMES_CAP: i64 = 512 |
| 89 | const NX_BD_VALUES_CAP: i64 = 16384 // 16K for body html |
| 103 | const NX_BUILD_VARS_BYTES: i64 = 72 |
functions
| 48 | func _bd_bcopy(dst: *u8, src: *u8, n: i64) -> i64 |
| 54 | func _bd_strlen(s: *u8, cap: i64) -> i64 |
| 64 | func _bd_append(dst: *u8, off: i64, cap: i64, |
| 106 | func nx_build_vars_init(bv: *NxBuildVars) -> i64 |
| 121 | func nx_build_vars_add(bv: *NxBuildVars, |
| 163 | func nx_build_vars_seal(bv: *NxBuildVars) -> i64 |
| 176 | func nx_build_vars_add_yaml(bv: *NxBuildVars, |
| 215 | func nx_build_apply_template(tmpl: *u8, tmpl_n: i64, |