HtmlDocumentLoader class final
Loads HTML by reducing it to readable text.
Scripts, styles and comments are dropped entirely; block-level tags become line breaks so paragraphs survive; the rest of the markup is removed and the five predefined entities plus numeric references are decoded.
This is a text extractor, not a parser. It is deliberately dependency-free, which is the right trade for the documentation, help centres and article pages that make up most retrieval corpora. A corpus of application HTML — where the content is assembled by script and the structure carries meaning — wants a real parser upstream, and this loader will happily take its output.
- Implemented types
Constructors
-
HtmlDocumentLoader(List<
TextSource> sources) -
Creates an HTML loader over
sources.const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
A short name, used in events and traces.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sources
→ List<
TextSource> -
The HTML texts to load.
final
Methods
-
load(
{AgenticContext? context}) → Future< List< RagDocument> > -
Produces documents from whatever this loader was constructed with.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
decodeEntities(
String text) → String - Decodes the predefined entities and numeric character references.
-
extractTitle(
String html) → String? -
The contents of
<title>, ornull. -
htmlToText(
String html) → String -
Reduces
htmlto readable text.