code wiki / _hdl_build / nx_fb2_book.nx

nx_fb2_book.nx

buildroot/runtime/_hdl_build/nx_fb2_book.nx

11225 B194 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tooltopic fb2
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itoa_lib.nx nx_html_to_text.nx nx_chapter_split.nx nx_fb2_book.nx

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

main do_fb2 sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close fb_p fb_w sys_write fb_slen find_sub fb_slen ↻ elem_text find_sub ↻ cs_split_on cs_slen cs_find_sub cs_slen ↻ ensure_dir er_cat nx_html_to_text nx_html_to_text_x h2t_state_new sys_mmap ↻ sys_mmap ↻ h2t_scan_tag h2t_skip_to_gt h2t_scan_name h2t_is_name h2t_is_block_tag h2t_name_eq_lit h2t_lc h2t_lc ↻ h2t_is_suppress_tag h2t_name_eq_lit ↻ h2t_emit_newline h2t_name_eq_lit ↻

structs

none

consts

14const K_MAGIC_1024: i64 = 1024
86const FCAP: i64 = 8388608

functions

16func fb_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: fb_wfind_sub
17func fb_w(fd: i64, s: *u8) -> i64 { sys_write(fd, s, fb_slen(s)); return 0 }
called by 2: fb_pdo_fb2 calls 2: sys_writefb_slen
22func fb_n(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 2: fb_pndo_fb2 calls 1: nxi_fd
23func fb_p(s: *u8) -> i64 { fb_w(1, s); return 0 }
called by 2: do_fb2main calls 1: fb_w
24func fb_pn(v: i64) -> i64 { fb_n(1, v); return 0 }
called by 1: do_fb2 calls 1: fb_n
25func ensure_dir(path: *u8) -> i64 { __syscall(258, 0-100, path, 0x1ed, 0, 0, 0); return 0 }
called by 1: do_fb2
26func 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
28func find_sub(hay: *u8, hl: i64, needle: *u8) -> i64
called by 2: elem_textdo_fb2 calls 1: fb_slen
35func elem_text(hay: *u8, hl: i64, opentag: *u8, out: *u8, outcap: i64) -> i64
called by 1: do_fb2 calls 1: find_sub
45func er_wjson(fd: i64, s: *u8) -> i64
called by 1: do_fb2 calls 1: sys_write
50func utf8_put(out: *u8, o: i64, cp: i64) -> i64
called by 1: decode_numeric_refs
56func decode_numeric_refs(txt: *u8, n: i64, out: *u8, outcap: i64) -> i64
called by 1: do_fb2 calls 1: utf8_put
88func do_fb2(path: *u8, slug: *u8) -> i64
187func main(argc: i64, argv: *i64) -> i64