lmhtml reference

Command-line flags, native commands, exit codes, host types, methods and standard-library signatures of lmhtml 0.7.6. Signatures are copied from lmhtml --lmcode-signatures, which prints 305 lines: 2 context objects, 71 host methods on 7 host types, 6 host functions, and the 226 canonical signatures of the lmcode_std_v3 standard catalog.

Host protocol flags

CommandEffect
lmhtml --versionPrints lmhtml and the version number.
lmhtml --lmcode-schemaPrints the schema summary: contexts, functions and each type with its methods.
lmhtml --lmcode-schema --jsonPrints the embedded schema JSON (dsl.schema 2, name lmhtml) used by the lmscript compiler.
lmhtml --lmcode-signaturesPrints every registered canonical signature, host and standard, one per line.
lmhtml [--dry-run] --lmcode FILE [FILE ...]Runs compiled program files written by run_lmcode. With --dry-run, saves are reported but not written.

With no arguments or a bad flag the host prints its usage text and a JSON envelope with code CLI_USAGE between the lines LMCODE_RETURN_BEGIN and LMCODE_RETURN_END.

Native commands

CommandFlagsEffect
lmhtml md2html IN.md [OUT.html]--template FILE, --allow-htmlConvert Markdown to HTML. Prints HTML when no output file is given. Raw HTML is disabled unless --allow-html is given.
lmhtml index DIR--order FILE, --checkWrite DIR/index.md. With --check nothing is written and index drift fails.
lmhtml mdcheck DIRCheck the Markdown notes in a directory; broken links fail.
lmhtml site DIR OUT--template FILEBuild a static note site from a notes directory.
lmhtml lint PATHS--stats, --json, --config FILE, --compare BEFORECount plain-content violations per file and in total. The config file holds DIRECTORY METRIC MAX_COUNT rows.
lmhtml md-lint PATHSMarkdown variant of lint listed in the usage text.
lmhtml normalize PATHS--checkRemove inline typography, repair entities and unfold prose without changing the text.
lmhtml clean URL-or-file--base URL, --markdown, --checkExtract main content. Files are processed offline; URL input uses curl. --check fails with a diff if content would be dropped.

Exit codes

CodeMeaning
0Success.
2Usage error: the usage text is printed.
3Program load failure, host runtime error, or a native command error such as an unknown option or index drift.
4Application failure, such as a report marked failed with fail_if_any, or an output stream error.

Used from lmscript

FormMeaning
p = _lmcode_ cli="lmhtml" install="github:lmctl-ai/lmhtml@latest"; ... end _lmcode_Declares a block compiled against the lmhtml schema; install lets lmscript download the release binary.
r = run_lmcode(p)Runs the block on the host and returns a map with ok and result.
$return.name = valueSets a named field of the result, as in the repository README example.
lmscript --check FILE.lmsCompiles every block against the host schema without running it.

Context objects and host types

NameKindRole
htmlContext object of type HtmlLoading, parsing, link checks, diffs, templates, Markdown and saving.
reportContext object of type ReportCollects findings and writes text or JSON reports.
DocHost typeOne parsed HTML document.
DocListHost typeA collection of documents from load_dir.
NodeHost typeOne element selected from a document.
NodeListHost typeResult of a select call.
ImageSizeHost typeWidth and height returned by png_size.

Html methods

SignatureNotes
Html.check_markdown(string) -> voidCheck Markdown notes under a directory (the mdcheck command).
Html.diff(Doc, Doc) -> intStructural difference count; ignores whitespace, comments, attribute order and data-* attributes.
Html.from_markdown(string) -> DocMarkdown to document; the bool form allows raw HTML.
Html.from_markdown(string, bool) -> DocMarkdown to document; the bool form allows raw HTML.
Html.index_markdown(string, string) -> stringReturn generated index text for a notes directory (the index command).
Html.link_exists(Doc, string) -> boolTrue when the internal destination exists.
Html.link_kind(Doc, string) -> stringClassify a link; kinds include external, special and outside-root. Nothing is fetched.
Html.load(string) -> DocLoad one HTML file.
Html.load_dir(string) -> DocListLoad a directory of pages; the three-argument form adds include and exclude globs on relative paths.
Html.load_dir(string, string, string) -> DocListLoad a directory of pages; the three-argument form adds include and exclude globs on relative paths.
Html.parse(string) -> DocParse an HTML string into a document.
Html.png_size(string) -> ImageSize
Html.render_markdown(string, string, string) -> Doc
Html.resolve(Doc, string) -> string
Html.save(Doc, string) -> voidAtomic write confined to the working directory; honours --dry-run.
Html.save(string, string) -> voidAtomic write confined to the working directory; honours --dry-run.
Html.site(string, string, string) -> voidBuild a static note site (the site command).
Html.write_template(DocList, int, string) -> intWrite shared subtrees with slot markers for pages sharing at least the given count.

Doc methods

SignatureNotes
Doc.byte_size() -> int
Doc.classes_used() -> StrList
Doc.clean(string) -> stringMain-content extraction against a base URL (the clean command).
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() -> stringPlain-content normalisation (the normalize command).
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 methods

SignatureNotes
DocList.at(int) -> Doc
DocList.classes_used() -> StrList
DocList.css_classes() -> StrList
DocList.css_ids() -> StrList
DocList.ids() -> StrList
DocList.len() -> int

Node methods

SignatureNotes
Node.append_html(string) -> Node
Node.attr(string) -> string
Node.attributes() -> StrList
Node.get_attrs(StrList) -> StrMapFresh StrMap of the requested attributes that are present.
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) -> NodeBulk set; all names and values are validated before the first edit.
Node.tag() -> string
Node.text() -> string

NodeList methods

SignatureNotes
NodeList.at(int) -> Node
NodeList.len() -> int

Report methods

SignatureNotes
Report.add(string, string, int, string) -> void
Report.fail_if_any() -> voidMarks the run failed when the report has entries.
Report.write_json(string) -> void
Report.write_text(string) -> void

ImageSize methods

SignatureNotes
ImageSize.height() -> int
ImageSize.width() -> int

Host functions

Signature
assert_close(float, float, float) -> void
print(string) -> void
str_difference(StrList, StrList) -> StrList
str_text_prefix(string, int) -> string
str_union(StrList, StrList) -> StrList
suggest(string, StrList) -> StrList

Standard catalog lmcode_std_v3

lmhtml 0.7.6 embeds the 226-signature lmcode_std_v3 catalog from the vendored lmcode-cpp SDK pinned in sdk.lock. The tables list the signatures exactly as the binary reports them.

Standard functions

GroupSignatures
filefile_append(string, string) -> void; file_exists(string) -> bool; file_lines(string) -> StrList; file_read(string) -> string; file_write(string, string) -> void
constructors and jsonfloat_list() -> FloatList; float_map() -> FloatMap; float_pq() -> FloatPQ; float_queue() -> FloatQueue; float_stack() -> FloatStack; int_list() -> IntList; int_map() -> IntMap; int_pq() -> IntPQ; int_queue() -> IntQueue; int_stack() -> IntStack; json_parse(string) -> Json; str_list() -> StrList; str_map() -> StrMap; str_pq() -> StrPQ; str_queue() -> StrQueue; str_stack() -> StrStack; template_render(string, Json) -> string
lmcode_returnlmcode_return_null() -> void; lmcode_return_put(string, FloatList) -> void; lmcode_return_put(string, FloatMap) -> void; lmcode_return_put(string, IntList) -> void; lmcode_return_put(string, IntMap) -> void; lmcode_return_put(string, Json) -> void; lmcode_return_put(string, StrList) -> void; lmcode_return_put(string, StrMap) -> void; lmcode_return_put(string, bool) -> void; lmcode_return_put(string, float) -> void; lmcode_return_put(string, int) -> void; lmcode_return_put(string, string) -> void; lmcode_return_put_null(string) -> void; lmcode_return_set(FloatList) -> void; lmcode_return_set(FloatMap) -> void; lmcode_return_set(IntList) -> void; lmcode_return_set(IntMap) -> void; lmcode_return_set(Json) -> void; lmcode_return_set(StrList) -> void; lmcode_return_set(StrMap) -> void; lmcode_return_set(bool) -> void; lmcode_return_set(float) -> void; lmcode_return_set(int) -> void; lmcode_return_set(string) -> void
mathmath_abs(float) -> float; math_abs(int) -> int; math_ceil(float) -> float; math_ceil(int) -> int; math_floor(float) -> float; math_floor(int) -> int; math_max(float, float) -> float; math_max(int, int) -> int; math_min(float, float) -> float; math_min(int, int) -> int; math_pow(float, float) -> float; math_pow(int, int) -> int; math_round(float) -> float; math_round(int) -> int; math_sqrt(float) -> float; math_sqrt(int) -> int
strstr_base64_decode(string) -> string; str_base64_encode(string) -> string; str_contains(string, string) -> bool; str_ends_with(string, string) -> bool; str_find(string, string) -> int; str_hex_decode(string) -> string; str_hex_encode(string) -> string; str_is_float(string) -> bool; str_is_int(string) -> bool; str_len(string) -> int; str_lower(string) -> string; str_match(string, string) -> bool; str_repeat(string, int) -> string; str_replace(string, string, string) -> string; str_split(string, string) -> StrList; str_starts_with(string, string) -> bool; str_substr(string, int, int) -> string; str_to_float(string) -> float; str_to_int(string) -> int; str_trim(string) -> string; str_upper(string) -> string

Standard types

TypeMethods
FloatListadd(float) -> FloatList; at(int) -> float; clear() -> FloatList; contains(float) -> bool; index_of(float) -> int; len() -> int; set(int, float) -> FloatList
FloatMapclear() -> FloatMap; get(string) -> float; get_or(string, float) -> float; has(string) -> bool; key_at(int) -> string; keys() -> StrList; len() -> int; remove(string) -> bool; set(string, float) -> FloatMap; values() -> FloatList
FloatPQclear() -> FloatPQ; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float, float) -> FloatPQ
FloatQueueat(int) -> float; clear() -> FloatQueue; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float) -> FloatQueue
FloatStackat(int) -> float; clear() -> FloatStack; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float) -> FloatStack
IntListadd(int) -> IntList; at(int) -> int; clear() -> IntList; contains(int) -> bool; index_of(int) -> int; len() -> int; set(int, int) -> IntList
IntMapclear() -> IntMap; get(string) -> int; get_or(string, int) -> int; has(string) -> bool; key_at(int) -> string; keys() -> StrList; len() -> int; remove(string) -> bool; set(string, int) -> IntMap; values() -> IntList
IntPQclear() -> IntPQ; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int, float) -> IntPQ
IntQueueat(int) -> int; clear() -> IntQueue; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int) -> IntQueue
IntStackat(int) -> int; clear() -> IntStack; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int) -> IntStack
Jsonas_bool() -> bool; as_float() -> float; as_int() -> int; as_string() -> string; at(int) -> Json; get(string) -> Json; has(string) -> bool; keys() -> StrList; kind() -> string; len() -> int; to_json() -> string
StrListadd(string) -> StrList; at(int) -> string; clear() -> StrList; contains(string) -> bool; index_of(string) -> int; join(string) -> string; len() -> int; set(int, string) -> StrList
StrMapclear() -> StrMap; get(string) -> string; get_or(string, string) -> string; has(string) -> bool; key_at(int) -> string; keys() -> StrList; len() -> int; remove(string) -> bool; set(string, string) -> StrMap; values() -> StrList
StrPQclear() -> StrPQ; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string, float) -> StrPQ
StrQueueat(int) -> string; clear() -> StrQueue; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string) -> StrQueue
StrStackat(int) -> string; clear() -> StrStack; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string) -> StrStack

Standard REST and CLI interfaces

A function inside a block implements one of ten standard interfaces and carries a route, command or option annotation written as @"..." on the line before it. Each handler takes one RestExchange. The README example dispatches them statelessly with rest_cli.

InterfaceAnnotationRole
RestGetroute path such as /healthHandles HTTP GET requests for the route.
RestPostroute path such as /healthHandles HTTP POST requests for the route.
RestPutroute path such as /healthHandles HTTP PUT requests for the route.
RestDeleteroute path such as /healthHandles HTTP DELETE requests for the route.
RestPatchroute path such as /healthHandles HTTP PATCH requests for the route.
RestHeadroute path such as /healthHandles HTTP HEAD requests for the route.
RestOptionsroute path such as /healthHandles HTTP OPTIONS requests for the route.
RestHandlerroute pathGeneral route handler interface.
CliCommandcommand name such as textA stateless CLI command.
CliOptionoption name such as --selectorA CLI option handler, run before the command.

REST functions

SignatureNotes
rest_cli(StrList) -> stringStateless dispatch of options, commands and REST routes from an argument list; returns the response text.
rest_config(string, string) -> voidSet a configuration key, for example session to global.
rest_route(string, string, string) -> voidRegister a route explicitly.
rest_serve() -> voidServe the declared routes.
rest_stop() -> voidStop serving.

RestExchange methods

Signature
RestExchange.body() -> string
RestExchange.get(string) -> string
RestExchange.has_header(string) -> bool
RestExchange.has_query(string) -> bool
RestExchange.header(string) -> string
RestExchange.increment(string) -> int
RestExchange.json(string) -> void
RestExchange.method() -> string
RestExchange.param(string) -> string
RestExchange.path() -> string
RestExchange.query(string) -> string
RestExchange.send(string) -> void
RestExchange.set(string, string) -> void
RestExchange.set_header(string, string) -> void
RestExchange.status(int) -> void

See the guide for concepts and the skill for the working procedure.