code wiki / _hdl_build / nx_reader_render.nx
nx_reader_render.nx
buildroot/runtime/_hdl_build/nx_reader_render.nx
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
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
structs
| none |
consts
| 10 | const K_MAGIC_1024: i64 = 1024 |
| 11 | const K_MAGIC_8192: i64 = 8192 |
| 12 | const K_MAGIC_1099: i64 = 1099 |
| 13 | const K_MAGIC_1100: i64 = 1100 |
| 85 | const CAP: i64 = 4194304 |
functions
| 15 | func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 16 | func w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, slen(s)); return 0 } |
| 17 | func 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 } |
| 18 | func p(s: *u8) -> i64 { w(1, s); return 0 } |
| 21 | func wesc_n(fd: i64, s: *u8, n: i64) -> i64 |
| 33 | func wesc_z(fd: i64, s: *u8) -> i64 { wesc_n(fd, s, slen(s)); return 0 } |
| 35 | func jfrom(hay: *u8, hl: i64, start: i64, needle: *u8) -> i64 |
| 42 | func jint(hay: *u8, hl: i64, pos: i64) -> i64 called by 1: main |
| 53 | func jstr(hay: *u8, hl: i64, pos: i64, out: *u8, cap: i64) -> i64 |
| 67 | func jval_str(hay: *u8, hl: i64, key: *u8, out: *u8, cap: i64) -> i64 |
| 73 | func jnext(hay: *u8, hl: i64, posp: *i64) -> i64 called by 1: main |
| 88 | func line_eq(txt: *u8, s: i64, e: i64, title: *u8) -> i64 called by 1: render_text |
| 100 | func w_para_fn(fd: i64, s: *u8, n: i64) -> i64 |
| 128 | func render_text(fd: i64, txt: *u8, n: i64, slug: *u8, title: *u8) -> i64 |
| 170 | func main(argc: i64, argv: *i64) -> i64 |