code wiki / _hdl_build / nx_fb2_book.nx
nx_fb2_book.nx
buildroot/runtime/_hdl_build/nx_fb2_book.nx
about
nx_fb2_book.nx -- SOVEREIGN FB2 (FictionBook 2.0) -> Nishi format. The Nishi equivalent of Calibre's FB2 input
plugin (OSS = benchmark, NOT a dependency -- per the sovereignty law). FB2 is a SINGLE XML file:
<FictionBook><description><title-info><book-title>T</book-title>
<author><first-name>F</first-name><last-name>L</last-name></author></title-info></description>
<body> <section><title>..</title><p>..</p>..</section> .. </body></FictionBook>
Extract title/author from <description>, run nx_html_to_text over the <body> only (FB2's <p>/<emphasis> are
HTML-ish; unknown tags strip cleanly leaving the prose), emit the SAME book.json the zero-JS reader renders.
Rung 1: whole <body> -> one chapter (readable); <section> chapter-splitting + <binary> images = next rungs.
Usage: nx_fb2_book <fb2-path> <slug>. expect_exit: 0 license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_itoa_lib.nxnx_html_to_text.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
structs
| none |
consts
| 14 | const K_MAGIC_1024: i64 = 1024 |
| 86 | const FCAP: i64 = 8388608 |
functions
| 16 | func fb_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 17 | func fb_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, fb_slen(s)); return 0 } |
| 22 | func fb_n(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 23 | func fb_p(s: *u8) -> i64 { fb_w(1, s); return 0 } |
| 24 | func fb_pn(v: i64) -> i64 { fb_n(1, v); return 0 } |
| 25 | func ensure_dir(path: *u8) -> i64 { __syscall(258, 0-100, path, 0x1ed, 0, 0, 0); return 0 } called by 1: do_fb2 |
| 26 | func er_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){dst[off+i]=s[i];i=i+1} return off+i } called by 1: do_fb2 |
| 28 | func find_sub(hay: *u8, hl: i64, needle: *u8) -> i64 |
| 35 | func elem_text(hay: *u8, hl: i64, opentag: *u8, out: *u8, outcap: i64) -> i64 |
| 45 | func er_wjson(fd: i64, s: *u8) -> i64 |
| 50 | func utf8_put(out: *u8, o: i64, cp: i64) -> i64 called by 1: decode_numeric_refs |
| 56 | func decode_numeric_refs(txt: *u8, n: i64, out: *u8, outcap: i64) -> i64 |
| 88 | func do_fb2(path: *u8, slug: *u8) -> i64 |
| 187 | func main(argc: i64, argv: *i64) -> i64 |