code wiki / _hdl_build / nx_reader_render.nx

nx_reader_render.nx

buildroot/runtime/_hdl_build/nx_reader_render.nx

30265 B456 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic reader
docsdependenciesstructsconstsfunctions

about

nx_reader_render.nx -- SOVEREIGN, ZERO-JAVASCRIPT reader. Operator law: "we shouldn't be using js -- we want the nishi ecosystem everywhere." So ALL reader logic lives in this Nishi organ (parse book.json + chapters + toc + assets, lay out the page); the browser runs NO code at all. Interactions are pure HTML+CSS: - theme + font-size switching via hidden <input type=radio> + the `#id:checked ~ .app{--vars}` technique - the Contents drawer via native <details>/<summary> - navigation + TOC jumps via plain <a href="#cN"> anchors Output: knowledge/staging/media/reader_static_<slug>.html -- a self-contained page, 0 <script>, 0 third-party. Reads OUR own book.json (emitted by nx_epub_book) + chap<N>.txt + extracted images. expect_exit: 0 ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_reader_render.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close p w sys_write slen sys_exit jval_str jfrom slen ↻ jstr slen ↻ jfrom ↻ jint sys_openat_wr w ↻ wesc_z wesc_n w ↻ sys_write ↻ slen ↻ jstr ↻ wn sys_write ↻ sys_mmap ↻ jnext render_text line_eq jfrom ↻ w ↻ sys_write ↻ w_para_fn sys_mmap ↻ w ↻

structs

none

consts

10const K_MAGIC_1024: i64 = 1024
11const K_MAGIC_8192: i64 = 8192
12const K_MAGIC_1099: i64 = 1099
13const K_MAGIC_1100: i64 = 1100
85const CAP: i64 = 4194304

functions

15func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
16func w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, slen(s)); return 0 }
17func wn(fd: i64, v0: i64) -> i64 { var v: i64=v0; if v<0 { sys_write(fd,"-" 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(fd,o,k); return 0 }
called by 1: main calls 2: sys_writesys_mmap
18func p(s: *u8) -> i64 { w(1, s); return 0 }
called by 1: main calls 1: w
21func wesc_n(fd: i64, s: *u8, n: i64) -> i64
called by 1: wesc_z calls 2: wsys_write
33func wesc_z(fd: i64, s: *u8) -> i64 { wesc_n(fd, s, slen(s)); return 0 }
called by 2: w_para_fnmain calls 2: wesc_nslen
35func jfrom(hay: *u8, hl: i64, start: i64, needle: *u8) -> i64
called by 3: jval_strrender_textmain calls 1: slen
42func jint(hay: *u8, hl: i64, pos: i64) -> i64
called by 1: main
53func jstr(hay: *u8, hl: i64, pos: i64, out: *u8, cap: i64) -> i64
called by 2: jval_strmain
67func jval_str(hay: *u8, hl: i64, key: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 3: jfromjstrslen
73func jnext(hay: *u8, hl: i64, posp: *i64) -> i64
called by 1: main
88func line_eq(txt: *u8, s: i64, e: i64, title: *u8) -> i64
called by 1: render_text
100func w_para_fn(fd: i64, s: *u8, n: i64) -> i64
128func render_text(fd: i64, txt: *u8, n: i64, slug: *u8, title: *u8) -> i64
170func main(argc: i64, argv: *i64) -> i64