code wiki / _hdl_build / nx_book_titles_gate.nx

nx_book_titles_gate.nx

buildroot/runtime/_hdl_build/nx_book_titles_gate.nx

10464 B107 linesdepth 7pulls 14 transitivereach 0 importersview sourcekind gate/prooftopic book
docsdependenciesstructsconstsfunctions

about

nx_book_titles_gate.nx -- liar-kill gate for the "TOC just shows Chapter 1" fix. Two layers: PART 1 (unit): cs_extract_heading (shared by MOBI+KF8 via nx_chapter_split) must read <h1> OR <h2> OR <h3>, stripping nested inline tags -- the reason ~390 Kindle TOCs degraded to "Chapter N" was reading ONLY <h1>. PART 2 (e2e): build a nav-LESS EPUB (so the reader falls back to chapters[].title = nx_epub_book's chap_title) with a NESTED <h1><span>..</span></h1> chapter + an <h2>-only chapter, run the REAL nx_epub_book, and assert book.json carries the real heading text -- NOT the "Chapter 0"/"Chapter 1" fallback. Sovereign: opc_write + fork/exec, no shell. expect_exit: 0 license_tier: ORIGINAL

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_opc.nx nx_chapter_split.nx nx_book_titles_gate.nx

imports: nx_syscalls.nxnx_opc.nxnx_chapter_split.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main tg_p sys_write sys_mmap uchk sys_mmap ↻ cs_extract_heading cs_extract_tag cs_find_sub cs_slen tg_slen tg_p ↻ streq cs_extract_heading ↻ ensure_dir tg_n sys_write ↻ sys_mmap ↻ sys_exit

structs

none

consts

none

functions

13func tg_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: uchkmain calls 1: sys_write
14func tg_n(v0: i64) -> i64 { var v: i64=v0; if v<0 { sys_write(1,"-" as *u8,1); v=0-v } let b: *u8=sys_mmap(24); var k: i64=0; if v==0 {b[0]=48 as u8;k=1} while v>0 {b[k]=(48+(v%10)) as u8; v=v/10; k=k+1} let o: *u8=sys_mmap(24); var j: i64=0; while j<k {o[j]=b[k-1-j];j=j+1} sys_write(1,o,k); return 0 }
called by 1: main calls 2: sys_writesys_mmap
15func tg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: hassubuchk
16func ensure_dir(path: *u8) -> i64 { __syscall(258, 0-100, path, 0x1ed, 0, 0, 0); return 0 }
called by 1: main
19func streq(out: *u8, exp: *u8) -> i64
called by 1: uchk
26func hassub(buf: *u8, n: i64, needle: *u8) -> i64
calls 1: tg_slen
32func run2(path: *u8, a0: *u8, a1: *u8, redir: *u8) -> i64
47func uchk(label: *u8, html: *u8, exp: *u8, pf: *i64) -> i64
55func main() -> i64