lmhtml API
Overview
lmhtml 0.7.6 is a native host for link and CSS audits, structural page diffs, shared-template extraction and safe HTML rewrites. It also converts Markdown, generates chapter indexes and builds static note sites.
Install and run
Use Node.js 24.15 or newer with lmscript 0.2.482 or newer. A block declared as p = _lmcode_ with cli="lmhtml" install="github:lmctl-ai/lmhtml@latest" downloads the platform release, checks its SHA-256 and compiles against its embedded schema; r = run_lmcode(p) runs it and returns a map with ok and result, and the block ends with end _lmcode_.
lmhtml --version
lmhtml --lmcode-schema
lmhtml --lmcode-schema --json
lmhtml --lmcode-signatures
lmscript --check audit.lms
lmscript audit.lms
--lmcode-schema prints a summary, --lmcode-schema --json prints the compiler schema bytes, and --lmcode-signatures prints canonical host signatures. run_lmcode drives lmhtml --lmcode FILE itself. The full member list, including Node.append_html, prepend_html, set_attrs and get_attrs added since 0.7.3, is in the reference; the host-specific summary follows.
Standard catalog and REST and CLI interfaces
lmhtml 0.7.6 embeds the 226-signature lmcode_std_v3 standard catalog. It includes the standard interfaces RestGet, RestPost, RestPut, RestDelete, RestPatch, RestHead, RestOptions, RestHandler, CliCommand and CliOption, the functions rest_config, rest_route, rest_serve, rest_stop and rest_cli, and the RestExchange type with 15 methods. A handler is a block function that implements one interface and carries an annotation such as @"/health", @"text" or @"--selector"; rest_cli(args) dispatches options, commands and routes statelessly and returns the response text. The reference lists every signature.
Contexts and functions
context html: Html
context report: Report
fn str_contains(string, string) -> bool
fn str_difference(StrList, StrList) -> StrList
fn str_ends_with(string, string) -> bool
fn str_find(string, string) -> int
fn str_len(string) -> int
fn str_list() -> StrList
fn str_lower(string) -> string
fn str_match(string, string) -> bool
fn str_replace(string, string, string) -> string
fn str_starts_with(string, string) -> bool
fn str_substr(string, int, int) -> string
fn str_text_prefix(string, int) -> string
fn str_trim(string) -> string
fn str_union(StrList, StrList) -> StrList
fn suggest(string, StrList) -> StrList
Document and collection methods
Doc.byte_size() -> int
Doc.classes_used() -> StrList
Doc.clean(string) -> string
Doc.css_classes() -> StrList
Doc.css_ids() -> StrList
Doc.doctype() -> string
Doc.ids() -> StrList
Doc.links() -> StrList
Doc.markdown(string) -> string
Doc.markup_errors() -> StrList
Doc.normalize() -> string
Doc.path() -> string
Doc.select(string) -> NodeList
Doc.source() -> string
Doc.source_elements(string) -> StrList
Doc.source_inner(string) -> string
Doc.source_inner(string, string) -> string
Doc.source_outer(string) -> string
Doc.summary() -> string
Doc.title() -> string
DocList.at(int) -> Doc
DocList.classes_used() -> StrList
DocList.css_classes() -> StrList
DocList.css_ids() -> StrList
DocList.ids() -> StrList
DocList.len() -> int
HTML operations
Html.check_markdown(string) -> void
Html.diff(Doc, Doc) -> int
Html.from_markdown(string) -> Doc
Html.from_markdown(string, bool) -> Doc
Html.index_markdown(string, string) -> string
Html.link_exists(Doc, string) -> bool
Html.link_kind(Doc, string) -> string
Html.load(string) -> Doc
Html.load_dir(string) -> DocList
Html.load_dir(string, string, string) -> DocList
Html.parse(string) -> Doc
Html.png_size(string) -> ImageSize
Html.render_markdown(string, string, string) -> Doc
Html.resolve(Doc, string) -> string
Html.save(Doc, string) -> void
Html.save(string, string) -> void
Html.site(string, string, string) -> void
Html.write_template(DocList, int, string) -> int
Node, report and image methods
Node.append_html(string) -> Node
Node.attr(string) -> string
Node.attributes() -> StrList
Node.get_attrs(StrList) -> StrMap
Node.has_attr(string) -> bool
Node.hash() -> int
Node.insert_after(string) -> Node
Node.insert_before(string) -> Node
Node.outer_html() -> string
Node.parent() -> Node
Node.path() -> string
Node.prepend_html(string) -> Node
Node.remove() -> void
Node.replace_with(string) -> Node
Node.select(string) -> NodeList
Node.set_attr(string, string) -> Node
Node.set_attrs(StrMap) -> Node
Node.tag() -> string
Node.text() -> string
NodeList.at(int) -> Node
NodeList.len() -> int
Report.add(string, string, int, string) -> void
Report.fail_if_any() -> void
Report.write_json(string) -> void
Report.write_text(string) -> void
ImageSize.height() -> int
ImageSize.width() -> int
Host behavior and limits
Directory loads can filter relative paths with include and exclude globs. Link checks classify local pages, assets, anchors, external URLs, special schemes and paths outside the site root; they do not fetch external URLs. Structural diffs ignore whitespace, comments, attribute order and data-* attributes. Template extraction finds shared subtrees and inserts slot markers. Saves are atomic and confined to the working directory; use --dry-run before rewriting pages.
The host has no execution budget or allocation cap, so run only trusted bytecode. HTML saves require valid UTF-8 and can normalize wrappers, tag casing, attribute quoting and optional elements.
Markdown and plain-content commands
Markdown input uses CommonMark with GFM tables, task lists, strikethrough and autolinks. Raw HTML is disabled by default. Index generation is deterministic; --check reports drift without writing. A trusted site template can use title, summary, path, content and toc placeholders.
lmhtml md2html notes/chapter.md build/chapter.html lmhtml index notes lmhtml index notes --check lmhtml mdcheck notes lmhtml site notes build/notes --template shell.html lmhtml lint --stats --json pages lmhtml normalize pages lmhtml clean page.html --check
See the runnable example book for focused tasks and the quickstart for solo and trio provider sessions.