Skip to main content

htmlToText

@forge/monorepo


@forge/monorepo / backend/src / htmlToText

Function: htmlToText()

htmlToText(html): string

Defined in: backend/src/toolkit/web.ts:22

Strip HTML to something a model can read.

Crude and openly so: script and style bodies removed, tags dropped, entities for the five characters that matter, whitespace collapsed. It is not a parser and does not need to be — the goal is legible text, and a DOM implementation is both a dependency and an attack surface for a tool whose output is prose either way.

script and style go with their contents; otherwise a page's JavaScript arrives as sentences and the model reads minified code as content.

Parameters

html

string

Returns

string