code wiki / (root) / nx_html_extract.nx

nx_html_extract.nx

buildroot/runtime/nx_html_extract.nx

21962 B601 linesdepth 2pulls 2 transitivereach 34 importersview sourcekind librarytopic html
docsdependenciesstructsconstsfunctions

about

nx_html_extract.nx -- minimal HTML body-text scraper (state-machine V2). Takes raw HTML bytes (a literotica chapter page, an nhentai gallery info page, a fanfiction.net story, a generic blog post) and emits: - body text (with block tags reduced to newline boundaries) - the first <title>...</title> content PRIORITY: faithful source preservation. Per user spec ("as close to possible to the source") we do NOT normalize whitespace, do NOT collapse newlines into spaces, do NOT re-flow paragraphs. We only: - strip <script>...</script> blocks (executable) - strip <style>...</style> blocks (rendering) - strip <!-- HTML comments --> - strip every other tag's MARKUP, keeping its TEXT CONTENT - decode the common HTML entities Block-level tags (<p>, <br>, <div>, <li>, <h1>..<h6>) cause a newline to be emitted at the open and close, so paragraph structure survives. Per cardinal feedback-build-intelligence-never-strip-features: when we encounter an unfamiliar tag, we strip the tag but KEEP the text content. Silent content stripping is forbidden. nx_safety_envelope: intended_use: "Extract <title> and readable body text from arbitrary HTML, preserving source text bytes verbatim outside of tag/entity markup." sil_target: SIL2 asil_target: QM dal_target: DAL C iec_62304_class: NONE evidence: [no_floating_point, bounded_loops_per_jpl_rule_2, adversarial_html_strips_script_style, entity_decode_table_static, explicit_state_machine_no_ad_hoc_breaks, no_re_flow_or_normalization_of_body_text] hazard_register: [bug-tape-malformed-unclosed-script-tag,

dependencies 1 imports · 10 importers

nx_syscalls.nx nx_html_extract.nx nx_caption_emit_test.nx nx_doc_extractor_md.nx nx_doc_extractor_nx.nx nx_html_to_nishi_page.nx nx_ingest_cli.nx nx_nishi_page_validator.nx nx_pipeline_graph_builder.nx nx_pipeline_recursive_walker.nx nx_pipeline_walker.nx nx_wiki_doc_handler.nx

imports: nx_syscalls.nx

imported by: nx_caption_emit_test.nxnx_doc_extractor_md.nxnx_doc_extractor_nx.nxnx_html_to_nishi_page.nxnx_ingest_cli.nxnx_nishi_page_validator.nxnx_pipeline_graph_builder.nxnx_pipeline_recursive_walker.nxnx_pipeline_walker.nxnx_wiki_doc_handler.nx

structs

53struct HtmlExtract

consts

60const NX_HTML_EXTRACT_BYTES: i64 = 32
327const NX_HE_STATE_NORMAL: i64 = 0
328const NX_HE_STATE_TAG_NAME: i64 = 1
329const NX_HE_STATE_TAG_ATTRS: i64 = 2
330const NX_HE_STATE_SCRIPT: i64 = 3
331const NX_HE_STATE_STYLE: i64 = 4
332const NX_HE_STATE_COMMENT: i64 = 5
333const NX_HE_STATE_TITLE: i64 = 6
335const NX_HE_TITLE_CAP: i64 = 512

functions

64func nx_he_load_u8(p: *u8, i: i64) -> i64
69func nx_he_store_u8(p: *u8, i: i64, v: i64)
74func nx_he_to_lower(c: i64) -> i64
called by 1: nx_he_match_ci
83func nx_he_match_ci(hay: *u8, off: i64, hay_n: i64,
98func nx_he_is_block_tag_name(src: *u8, off: i64, end: i64) -> i64
called by 1: nx_html_extract calls 1: nx_he_match_ci
156func nx_he_decode_entity(src: *u8, off: i64, n: i64,
337func nx_html_extract(src: *u8, n: i64) -> *HtmlExtract