nx_frontmatter.nx
buildroot/runtime/nx_frontmatter.nx
about
nx_frontmatter.nx -- splits "---\n<yaml>\n---\n<body>" into YAML
+ body slices. Mirrors what nishi-pages/build/build.py load_doc()
did in Python; substrate-native + bounded + auditable.
Wire format (mandatory):
src[0..3] == "---\n" (3 dashes + newline)
src[3..yaml_end] == YAML subset bytes
src[yaml_end..yaml_end+4] == "\n---" (terminator) OR "\n---\n"
src[yaml_end+5..] == body bytes (markdown, plain text, anything)
Returns:
yaml_off / yaml_len = slice of the YAML subset block
body_off / body_len = slice of the body bytes
Used by:
nishi-pages content/posts/*.md, content/pages/*.md (YAML front-
matter + markdown body)
Per cardinal feedback-defensive-at-boundaries: input must START
with literal "---\n" or NX_FM_NO_FRONTMATTER returns; YAML term
must be present or NX_FM_UNTERMINATED returns.
dependencies 1 imports · 2 importers
imports: nx_syscalls_x86_64.nx
imported by: nx_build_doc.nxnx_build_site.nx
structs
| none |
consts
| 33 | const NX_FM_OK: i64 = 0 |
| 34 | const NX_FM_BAD_INPUT: i64 = 1 // src null / len < 4 |
| 35 | const NX_FM_NO_FRONTMATTER: i64 = 2 // doesn't start with "---\n" |
| 36 | const NX_FM_UNTERMINATED: i64 = 3 // no closing "\n---" found |
| 37 | const NX_FM_VERDICT_N: i64 = 4 |
functions
| 39 | func _fm_match4(src: *u8, off: i64, n: i64, called by 1: nx_frontmatter_split |
| 54 | func nx_frontmatter_split(src: *u8, src_n: i64, |