lmhtml

lmhtml is a native host for auditing links and CSS names, comparing HTML documents, extracting templates, applying shared-page edits, converting Markdown and producing plain content for agents. This page is the quick reference for lmhtml 0.7.6; scripts reach it through an _lmcode_ block and run_lmcode, and the native commands need only the binary.
Install and run
npm install -g @lmctl-ai/lmctl
lmscript --check audit.lms
lmscript audit.lms
lmhtml --version
lmhtml --lmcode-signatures
A block that declares cli="lmhtml" install="github:lmctl-ai/lmhtml@latest" lets lmscript download the release binary and compile against its embedded schema.
Minimal example
p = _lmcode_ cli="lmhtml" install="github:lmctl-ai/lmhtml@latest";
let d = html.parse("<main><h1 id=\"top\">Hello</h1><a href=\"#top\">Top</a></main>");
let h = d.select("h1");
$return.title = h.at(0).text();
$return.links = d.links().len();
end _lmcode_
r = run_lmcode(p);
require(r.ok, json_stringify(r));
println(json_stringify(r));
lmscript audit.lms
{"ok":true,"result":{"title":"Hello","links":1}}
Host protocol and native commands
| Command | Effect |
|---|---|
| lmhtml --version | Print the version. |
| lmhtml --lmcode-schema [--json] | Print the schema summary, or the compiler schema JSON. |
| lmhtml --lmcode-signatures | Print all 305 canonical signatures: host API plus the 226-signature lmcode_std_v3 catalog. |
| lmhtml [--dry-run] --lmcode FILE [FILE ...] | Run compiled program files; this is what run_lmcode calls. |
| lmhtml md2html IN.md [OUT.html] [--template FILE] [--allow-html] | Markdown to HTML. |
| lmhtml index DIR [--order FILE] [--check] | Generate or check DIR/index.md. |
| lmhtml mdcheck DIR | Check Markdown notes and their links. |
| lmhtml site DIR OUT [--template FILE] | Build a static note site. |
| lmhtml lint [--stats] [--json] [--config FILE] [--compare BEFORE] PATHS | Count plain-content violations. |
| lmhtml normalize [--check] PATHS | Rewrite pages as plain content. |
| lmhtml clean URL-or-file [--base URL] [--markdown] [--check] | Extract main content for agents. |
Exit codes: 0 success, 2 usage, 3 load or runtime error, 4 application failure.
Host objects
| Name | Main members |
|---|---|
| html (context, type Html) | load, load_dir, parse, save, diff, link_kind, link_exists, resolve, write_template, from_markdown, render_markdown, check_markdown, index_markdown, site, png_size |
| report (context, type Report) | add, write_text, write_json, fail_if_any |
| Doc | select, links, ids, classes_used, css_classes, css_ids, title, summary, source, markup_errors, normalize, clean, markdown |
| DocList | len, at, ids, classes_used, css_classes, css_ids |
| Node | tag, text, attr, has_attr, attributes, get_attrs, set_attr, set_attrs, select, parent, outer_html, replace_with, insert_before, insert_after, append_html, prepend_html, remove |
| NodeList | len, at |
| ImageSize | width, height |
| Host functions | suggest, str_difference, str_union, str_text_prefix, print, assert_close |
| Standard catalog | 226 lmcode_std_v3 signatures: strings, math, files, JSON, typed lists, maps, queues, stacks, priority queues, lmcode_return and the REST and CLI interfaces with rest_config, rest_route, rest_serve, rest_stop, rest_cli and RestExchange |
More
Get started with a solo or trio provider session, or browse the runnable example book.