code wiki / (root) / nx_paper_native.nx

nx_paper_native.nx

buildroot/runtime/nx_paper_native.nx

40567 B855 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic paper
docsdependenciesstructsconstsfunctions

about

nx_paper_native.nx -- PAPERS AS NATIVE NISHI DOCS, NOT PDF (operator 2026-08-13: "i dont want the papers in 3rd party formats like pdf ... ingested into html or whatever from the first bit up we can do in nishi that makes it native to nishi os and browser"). NXPAP2 (2026-08-14) -- v1 was a readable DIGEST, measured NOT sota. Against the real LaTeXML source of one paper (arXiv 2411.15205, 242,460 B) v1 preserved: 0 of 82 <math>, 0 of 8 <figure>, 0 of 84 bibitems, and collapsed all 10 <h3> subsections into their parent section. It also DECODED source entities (&lt; -> <) and then copied section text into HTML unescaped, so decoded markup reached the page raw. NXPAP2 fixes all of it, and REFUSES rather than drop silently. FORMAT: line-oriented, greppable, sovereign. Header `KEY\tVALUE` lines, then typed blocks: .SEC <level>\t<id>\t<title> sectioning, level 1..3, id = the source anchor .PARA <inline> one paragraph of SAFE inline html (see below) .MATH <id>\t<mathml> display equation, MathML subtree VERBATIM .FIG <id> figure open | .TBL <id> table open .IMG <url> one image of the current figure (absolute url) .CAP <inline> caption of the current figure/table .ROW <cell>\t<cell>... one table row, cells are inline .REF <key>\t<label>\t<text> one parsed reference SAFE INLINE is the load-bearing invariant: source entities are kept VERBATIM (never decoded), every tag is dropped except (a) <math>..</math> copied byte-for-byte so MathML survives to the browser natively, and (b) fragment links rebuilt as anchors so citations and cross-references stay real links. Nothing else reaches the output, so the emitted page cannot carry injected markup -- escaping is by construction, not by a filter that must be remembered. FIDELITY IS ENFORCED, NOT HOPED FOR: the ingest counts <math>, <figure> and bibitems in the SOURCE and in what it EMITTED, prints both, and REFUSES (exit 3) if it emitted fewer. A silent drop -- the v1 defect -- is impossible by construction. nx_paper_native abs <cvf-abstract.raw> <out.nxpap> [arxiv-html.raw] nx_paper_native view <in.nxpap> <out.html> exit: 0 ok | 1 io | 2 usage | 3 refuse (named). license_tier: ORIGINAL. No hw writes (Rule 26).

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_paper_native.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_exit pn_ingest sys_mmap nxa_die sys_write sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_munmap sys_close pn_meta pn_hdr pn_meta ↻ pn_bodystart pn_body pn_bodystart ↻ pn_refs pn_figure pn_view sys_mmap ↻ sys_read_file ↻ pn_field

structs

none

consts

35const PN_MAGIC_1048576: i64 = 1048576
43const PN_ARXBASE: *u8 = "https://arxiv.org/html/"

functions

45func pn_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
46func pn_puts(s: *u8) -> i64 { sys_write(1, s, pn_len(s)); return 0 }
47func pn_num(v: i64) -> i64
59func pn_app(d: *u8, off: i64, s: *u8) -> i64
65func pn_appn(d: *u8, off: i64, src: *u8, a: i64, b: i64) -> i64
71func pn_find(src: *u8, a: i64, b: i64, pat: *u8) -> i64
92func pn_count(src: *u8, a: i64, b: i64, pat: *u8) -> i64
102func pn_num_to(d: *u8, off: i64, v: i64) -> i64
113func pn_attr_s(src: *u8, a: i64, b: i64, attr: *u8) -> i64
118func pn_write(path: *u8, buf: *u8, n: i64) -> i64
127func pn_txt(d: *u8, off: i64, src: *u8, a: i64, b: i64) -> i64
155func pn_inline(d: *u8, off: i64, src: *u8, a: i64, b: i64, cnt: *i64) -> i64
232func pn_figure(d: *u8, off: i64, src: *u8, a: i64, b: i64, istbl: i64, cnt: *i64) -> i64
315func pn_refs(d: *u8, off: i64, src: *u8, a: i64, b: i64, nref: *i64) -> i64
382func pn_bodystart(src: *u8, n: i64) -> i64
389func pn_body(d: *u8, off: i64, src: *u8, n: i64, cnt: *i64, nfig: *i64, nref: *i64, nsec: *i64) -> i64
508func pn_meta(src: *u8, a: i64, b: i64, key: *u8, r: *i64) -> i64
521func pn_hdr(out: *u8, off: i64, fb: *u8, n: i64, key: *u8, label: *u8, r: *i64) -> i64
532func pn_ingest(inp: *u8, outp: *u8, axp: *u8) -> i64
637func pn_field(fb: *u8, p: i64, e: i64, idx: i64, r: *i64) -> i64
654func pn_view(inp: *u8, outp: *u8) -> i64
839func main(argc: i64, argv: *i64) -> i64