Pure, sync HTML->text extraction mechanism: charset-aware decode (encoding_rs; declared charset -> <meta charset> sniff -> windows-1252 fallback, flags recorded), bounded-output structural extraction via lol_html (drops script/style/nav/svg/noscript/template/iframe + comments, outline-stack heading_path with skipped-level retention, output byte cap + per-heading char cap with per-class truncation flags), and section-aware chunking over infrastructure-embeddings::chunk_text with document-absolute char offsets taken from the chunker's returned spans. No I/O, no async, no lossy silent fallback -- the reusable extraction mechanism composed by infrastructure-web-ingest.
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/html-text |
| Edition | 2021 |
| Targets | infrastructure_html_text |
| Public items | 10 across 3 modules |
| Tests | 43 |
What it is for
infrastructure-html-text -- pure, synchronous HTML -> text extraction.
No I/O, no async, no network: bytes and config in, structured text out. Three stages, each independently testable and each mirroring an existing in-repo convention rather than inventing a new one:
1. decode -- bytes -> String via encoding_rs: declared charset -> <meta charset> sniff -> windows-1252 fallback, with a decode::DecodeReport so a lossy decode is never silent. 2. extract -- bounded-output HTML -> text via lol_html (the same streaming rewriter infrastructure-dom-reduce uses): drops script/style/nav/svg/noscript/template/iframe subtrees and comments, builds an outline-stack heading_path from h1-h6, and caps both total output and any single heading's length. 3. chunker -- section-aware chunking over infrastructure_embeddings::chunk_text, the same chunker tools-org-knowledge's markdown pipeline uses, with document-absolute char offsets read directly from the chunker's returned spans.
The reusable mechanism consumed by infrastructure-web-ingest, which adds fetch, storage, and the knowledge-index write.
Capabilities
ChunkInput
Section-aware chunking over infrastructure_embeddings::chunk_text.
| Item |
|---|
pub struct ChunkInput |
fn chunk_sections(sections : & Section, opts : & ChunkOptions) -> Vec <ChunkInput> |
DecodeReport
bytes -> String decode: declared charset -> <meta charset> sniff ->
| Item |
|---|
pub struct DecodeReport |
fn decode(bytes : & u8, declared_charset : Option <& str>) ->(String, DecodeReport) |
extract (other)
Bounded-output HTML -> text extraction via lol_html.
| Item |
|---|
fn extract(html : & str, cfg : & ExtractConfig) -> Extraction |
ExtractConfig
Bounded-output HTML -> text extraction via lol_html.
| Item |
|---|
pub struct ExtractConfig |
ExtractConfig :: fn default() -> Self |
Extraction
Bounded-output HTML -> text extraction via lol_html.
| Item |
|---|
pub struct Extraction |
Section
Bounded-output HTML -> text extraction via lol_html.
| Item |
|---|
pub struct Section |
TruncationFlags
Bounded-output HTML -> text extraction via lol_html.
| Item |
|---|
pub struct TruncationFlags |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
infrastructure_html_text
chunkerdecodeextract
flowchart TD n_infrastructure_html_text["infrastructure_html_text"] n_infrastructure_html_text --> n_chunker["chunker"] n_infrastructure_html_text --> n_decode["decode"] n_infrastructure_html_text --> n_extract["extract"]
Public surface
`chunker`
| Item | What it is |
|---|---|
pub struct ChunkInput | One embeddable chunk with document-absolute (concatenated-sections) char provenance |
fn chunk_sections(sections : & Section, opts : & ChunkOptions) -> Vec <ChunkInput> | Chunk every section, in order |
`decode`
| Item | What it is |
|---|---|
pub struct DecodeReport | What decode did: which encoding won and whether any byte was unmappable. |
fn decode(bytes : & u8, declared_charset : Option <& str>) ->(String, DecodeReport) | Decode bytes to a String, honoring declared_charset (typically the charset parameter of an HTTP Content-Type header) first, then sniffing a <meta charset>/<meta http-equiv> declaration in the first META_SNIFF_WINDOW bytes, then falling back to windows-1252 (the pragmatic default browsers use for undeclared legacy content) |
`extract`
| Item | What it is |
|---|---|
pub struct ExtractConfig | Extraction tuning. |
ExtractConfig :: fn default() -> Self | — |
pub struct Section | A contiguous run of extracted text under one heading trail |
pub struct TruncationFlags | Which caps fired |
pub struct Extraction | The result of one extraction pass. |
fn extract(html : & str, cfg : & ExtractConfig) -> Extraction | Extract text + heading outline from html |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
{chunk_sections,ChunkInput} | chunker::{chunk_sections,ChunkInput} |
{decode,DecodeReport} | decode::{decode,DecodeReport} |
{extract,ExtractConfig,Extraction,Section,TruncationFlags} | extract::{extract,ExtractConfig,Extraction,Section,TruncationFlags} |
Boundary
Depends on no other workspace tier.
Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | infrastructure |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/infrastructure/html-text |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `infrastructure-embeddings` | infrastructure | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
encoding_rs | ^0.8 | — | no | always |
lol_html | ^3.0.1 | — | no | always |
serde | ^1 | derive, derive | no | always |
Development. None.
Build. None.
Depended on by. 4 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_party_discovery["application-party-discovery"] -->|uses| SELF n_infrastructure_acquire["infrastructure-acquire"] -->|uses| SELF n_infrastructure_web_contact_extractor["infrastructure-web-contact-extractor"] -->|uses| SELF n_infrastructure_web_ingest["infrastructure-web-ingest"] -->|uses| SELF SELF["infrastructure-html-text"] SELF -->|runtime| n_infrastructure_embeddings["infrastructure-embeddings"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | infrastructure_html_text | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
4 workspace crates depend on this one: application-party-discovery, infrastructure-acquire, infrastructure-web-contact-extractor, infrastructure-web-ingest.
Verification
| Kind | Count |
|---|---|
| Unit tests | 43 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
chunker | 2 | 0 | 2 |
decode | 2 | 0 | 3 |
extract | 5 | 0 | 11 |
What the tests establish, by name:
a_section_of_only_whitespace_produces_no_chunks—src/chunker.rsadr_0016_defaults_are_2000_320—src/chunker.rsempty_sections_produce_no_chunks—src/chunker.rsheading_path_propagates_from_the_owning_section—src/chunker.rsoffsets_are_document_absolute_across_section_boundaries—src/chunker.rsspans_come_from_the_chunker_never_from_searching_the_document—src/chunker.rsunicode_content_offsets_are_char_based_not_byte_based—src/chunker.rscontradictory_meta_loses_to_declared_charset—src/decode.rsdeclared_windows_1252_decodes_high_bytes_correctly—src/decode.rsempty_input_decodes_to_empty_string_without_errors—src/decode.rsinvalid_utf8_bytes_with_declared_utf8_sets_had_errors—src/decode.rsmeta_charset_sniff_used_when_no_declared_charset—src/decode.rsmeta_http_equiv_content_type_charset_is_sniffed—src/decode.rsno_charset_information_falls_back_to_windows_1252—src/decode.rsunrecognized_declared_charset_falls_through_to_meta_sniff—src/decode.rsutf8_bytes_decode_as_utf8_with_no_errors—src/decode.rsblank_title_is_none—src/extract.rscomments_are_dropped—src/extract.rsempty_input_yields_empty_extraction—src/extract.rsfirst_h1_is_captured_normalized_and_skips_dropped_subtrees—src/extract.rsfirst_h1_is_none_when_only_lower_headings_exist—src/extract.rshead_without_title_element_yields_none—src/extract.rsheading_inside_dropped_subtree_does_not_pollute_the_outline—src/extract.rsheading_path_nests_and_pops_on_sibling—src/extract.rsheading_text_is_included_in_its_own_section—src/extract.rsmax_heading_chars_caps_a_single_heading_and_reports_it—src/extract.rsmax_output_bytes_caps_extraction_and_reports_it—src/extract.rsmixed_self_closed_and_properly_closed_drop_elements—src/extract.rsnested_inline_markup_inside_a_heading_concatenates—src/extract.rsno_headings_at_all_yields_one_preamble_section—src/extract.rs- _… 13 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 9 | 10 |
Public modules with a //! block | 3 | 3 |
pie showData
title Public items with rustdoc
"Documented" : 9
"No rustdoc detected" : 1
Metrics
| Metric | Value |
|---|---|
| Rust source files | 4 |
| Source lines | 1136 |
| Code lines | 779 |
| Public API items | 10 |
| Public modules | 3 |
| Tests | 43 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 4 |
| Workspace reverse dependencies | 4 |
pie showData
title Public API by kind
"function" : 3
"method" : 1
"struct" : 6
pie showData
title Rust source composition
"Code" : 779
"Blank or comment" : 357
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.