extract_html
Extract text and metadata from an HTML file.
Parameters
- pathstringone of
pathorsource_key - File path to the HTML file; supports
${ctx.key}interpolation. - source_keystringone of
pathorsource_key - Context key whose value is the file path (must be a string).
- formatstringdefault "text"
- Output format:
"text"for sanitized plain text,"markdown"for full HTML-to-Markdown conversion. - output_keystringdefault "content"
- Context key where the extracted content is stored.
- metadata_keystring
- If set, HTML metadata is stored under this context key.
Providing both
pathandsource_keyis an error. Theformatparameter only accepts"text"or"markdown"; any other value is rejected.
Context Output
<output_key>(defaultcontent) — the extracted text or Markdown.<metadata_key>(only whenmetadata_keyis set) — an object with available fields:title,description,author,keywords,viewport,og:title,og:description,og:type,og:url.
Example
local flow = Flow.new("read_html_file")
flow:step("extract", nodes.extract_html({
path = "/data/page.html",
format = "markdown",
output_key = "html_content",
metadata_key = "html_meta"
}))
flow:step("done", nodes.log({
message = "Title: ${ctx.html_meta.title}, Content: ${ctx.html_content}"
})):depends_on("extract")
return flow