nx_html_extract.nx
buildroot/runtime/nx_html_extract.nx
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
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
| 53 | struct HtmlExtract |
consts
| 60 | const NX_HTML_EXTRACT_BYTES: i64 = 32 |
| 327 | const NX_HE_STATE_NORMAL: i64 = 0 |
| 328 | const NX_HE_STATE_TAG_NAME: i64 = 1 |
| 329 | const NX_HE_STATE_TAG_ATTRS: i64 = 2 |
| 330 | const NX_HE_STATE_SCRIPT: i64 = 3 |
| 331 | const NX_HE_STATE_STYLE: i64 = 4 |
| 332 | const NX_HE_STATE_COMMENT: i64 = 5 |
| 333 | const NX_HE_STATE_TITLE: i64 = 6 |
| 335 | const NX_HE_TITLE_CAP: i64 = 512 |
functions
| 64 | func nx_he_load_u8(p: *u8, i: i64) -> i64 |
| 69 | func nx_he_store_u8(p: *u8, i: i64, v: i64) |
| 74 | func nx_he_to_lower(c: i64) -> i64 called by 1: nx_he_match_ci |
| 83 | func nx_he_match_ci(hay: *u8, off: i64, hay_n: i64, |
| 98 | func nx_he_is_block_tag_name(src: *u8, off: i64, end: i64) -> i64 |
| 156 | func nx_he_decode_entity(src: *u8, off: i64, n: i64, |
| 337 | func nx_html_extract(src: *u8, n: i64) -> *HtmlExtract |