Preview local HTML (structure, text, links, forms — read-only)
Render an HTML file or fragment the caller already has and get back its title, text, headings, links, images and forms — no network, no browser, nothing…
Render an HTML file or fragment the caller already has and get back its title, text, headings, links, images and forms — no network, no browser, nothing executed or submitted.
Also known as: html preview, preview html, render html, local file preview, local html, html file, dom preview
Call it
bowmark.local_html_preview.render(html: string, options?: PreviewOptions): Promise<HtmlPreviewResult>Functions
| Function | What it does |
|---|---|
render | Parses supplied HTML (a local file's contents, or a fragment) and returns a structured preview: title, readable text, headings, links, images and a read-only form inventory. |
Types
interface PreviewHeading { level: number; text: string }
interface PreviewLink { text: string; href: string | null }
interface PreviewImage { src: string | null; alt: string | null }
interface PreviewForm { action: string | null; method: string; fieldCount: number }
interface PreviewOptions {
maxChars?: number // default 20000; over it, text is cut + truncated:true
}
interface HtmlPreviewResult {
title: string | null
text: string // visible text, block structure kept as blank lines
chars: number
truncated: boolean
headings: PreviewHeading[]
links: PreviewLink[]
images: PreviewImage[]
forms: PreviewForm[] // inventory only — nothing here submits a form
wordCount: number
warnings: string[]
}Examples
// Preview HTML you already hold — a page you generated, or a file's contents
// your script already read into a string. No url, no browser.
const preview = await bowmark.local_html_preview.render(draftHtml);
log(`${preview.title} — ${preview.wordCount} words, ${preview.links.length} links`);
return { title: preview.title, headings: preview.headings, text: preview.text };// Check a generated page for a login form before deciding what to do next —
// this only reports the inventory, it never drives or submits anything.
const preview = await bowmark.local_html_preview.render(generatedHtml);
const hasLoginForm = preview.forms.some(f => f.fieldCount >= 2);
return { hasLoginForm, forms: preview.forms, images: preview.images };Providers behind it
None — this capability needs no site. It computes the answer, or reads a public API that publishes it.