code wiki / wiki / nx_wiki_cite_render.nx

nx_wiki_cite_render.nx

buildroot/runtime/wiki/nx_wiki_cite_render.nx

14865 B267 linesdepth 8pulls 10 transitivereach 24 importersview sourcekind librarytopic wiki
docsdependenciesstructsconstsfunctions

about

nx_wiki_cite_render.nx -- INLINE SUPPORTING-SOURCE RENDER (the anti-pushout). THE WIKIPEDIA-EXCEED DIFFERENTIATOR: Wikipedia's awful pushout = you click a citation and LEAVE the wiki to read a source that may be paywalled, rotted, or gone. We kill that: a citation token [[cite:<cid>]] in a page body renders the cited supporting source INLINE -- an expandable "read source here" card pulled from the no-link-rot content-addressed archive -- so the reader reads the evidence IN PLACE. ...BUT ONLY WHEN LICENSING PERMITS HOSTING IT. This is the critical liar-kill: public-domain / CC0 / every Creative-Commons variant = we may redistribute the bytes, so we inline them (with attribution). Proprietary / unknown = we are NOT licensed to host the content, so we render a LINK + license note ONLY and the source bytes NEVER appear in the output. We never inline content we are not licensed to host. CITATION SYNTAX (page-body token): [[cite:<cid>]] where <cid> is an archive content id, e.g. nxc1-<64hex> (or any NUL-safe slug the archive resolves via war_get_by_cid). The double-bracket shape mirrors the existing [[wikilink]] preprocessor; the "cite:" prefix disambiguates a supporting-source citation from a cross-reference link. THREE OUTCOMES per citation (decided from REAL archive + license lookups): 1. archived AND hostable -> INLINE EXPANDABLE card containing the HTML-ESCAPED source bytes (read in place). 2. archived, NOT hostable -> LINK + license note only; source bytes OMITTED. 3. not archived -> "(source archiving pending)" placeholder. XSS: every inlined source byte goes through html_escape (the sealed escaper) before reaching the output -- a source can never inject markup. FRONTEND: nx_wiki_cite_css() emits clean, self-contained CSS for the card (sovereign-emitted by this organ; no third-party JS/CSS framework). IMPORTS: nx_wiki_license.nx (license decision + getters; transitively the archive + seg_store + canon_cid, each spliced ONCE by module-identity dedup) and nx_html_escape.nx (the escaper; a DISTINCT module from the store chain, so no double-import). Pure NishiLang, NO SQL, NO .sh/.py/.js, no new .tsv/.conf. license_tier: ORIGINAL

dependencies 2 imports · 4 importers

nx_wiki_license.nx nx_html_escape.nx nx_wiki_cite_render.nx _wiki_cite_gate.nx _wiki_cite_live_gate.nx _wiki_frontend_gate.nx nx_wiki_doc_render.nx

imports: nx_wiki_license.nxnx_html_escape.nx

imported by: _wiki_cite_gate.nx_wiki_cite_live_gate.nx_wiki_frontend_gate.nxnx_wiki_doc_render.nx

structs

none

consts

44const NXCITE_OK: i64 = 0
45const NXCITE_OUTPUT_OVERFLOW: i64 = 1
46const NXCITE_BAD_INPUT: i64 = 2
48const NXCITE_CAP: i64 = 64 // archive segment-scan cap (>> our commits)
49const NXCITE_MAX_CID: i64 = 128 // a CID is ~69 bytes; this is headroom
50const NXCITE_MAX_ITER: i64 = 1000000 // hard outer-walk cap (M3 bounded loops)
53const NXCITE_LBRACKET: i64 = 0x5B // '['
54const NXCITE_RBRACKET: i64 = 0x5D // ']'
55const NXCITE_COLON: i64 = 0x3A // ':'

functions

58func cr_len(s: *u8) -> i64
66func cr_cat(dst: *u8, off: i64, s: *u8) -> i64
called by 1: nx_wiki_cite_one
73func cr_catb(dst: *u8, off: i64, src: *u8, n: i64) -> i64
85func nx_wiki_cite_css(out: *u8, cap: i64) -> i64
99func nx_wiki_cite_one(prefix: *u8, cid: *u8, out: *u8, cap: i64, off: i64) -> i64
187func nx_wiki_cite_render(prefix: *u8, src: *u8, src_n: i64,
called by 1: main calls 1: nx_wiki_cite_one