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
| Command | Effect |
|---|---|
| lmhtml --version | Prints lmhtml and the version number. |
| lmhtml --lmcode-schema | Prints the schema summary: contexts, functions and each type with its methods. |
| lmhtml --lmcode-schema --json | Prints the embedded schema JSON (dsl.schema 2, name lmhtml) used by the lmscript compiler. |
| lmhtml --lmcode-signatures | Prints 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
| Command | Flags | Effect |
|---|---|---|
| lmhtml md2html IN.md [OUT.html] | --template FILE, --allow-html | Convert 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, --check | Write DIR/index.md. With --check nothing is written and index drift fails. |
| lmhtml mdcheck DIR | Check the Markdown notes in a directory; broken links fail. | |
| lmhtml site DIR OUT | --template FILE | Build a static note site from a notes directory. |
| lmhtml lint PATHS | --stats, --json, --config FILE, --compare BEFORE | Count plain-content violations per file and in total. The config file holds DIRECTORY METRIC MAX_COUNT rows. |
| lmhtml md-lint PATHS | Markdown variant of lint listed in the usage text. | |
| lmhtml normalize PATHS | --check | Remove inline typography, repair entities and unfold prose without changing the text. |
| lmhtml clean URL-or-file | --base URL, --markdown, --check | Extract main content. Files are processed offline; URL input uses curl. --check fails with a diff if content would be dropped. |
Exit codes
| Code | Meaning |
|---|---|
| 0 | Success. |
| 2 | Usage error: the usage text is printed. |
| 3 | Program load failure, host runtime error, or a native command error such as an unknown option or index drift. |
| 4 | Application failure, such as a report marked failed with fail_if_any, or an output stream error. |
Used from lmscript
| Form | Meaning |
|---|---|
| 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 = value | Sets a named field of the result, as in the repository README example. |
| lmscript --check FILE.lms | Compiles every block against the host schema without running it. |
Context objects and host types
| Name | Kind | Role |
|---|---|---|
| html | Context object of type Html | Loading, parsing, link checks, diffs, templates, Markdown and saving. |
| report | Context object of type Report | Collects findings and writes text or JSON reports. |
| Doc | Host type | One parsed HTML document. |
| DocList | Host type | A collection of documents from load_dir. |
| Node | Host type | One element selected from a document. |
| NodeList | Host type | Result of a select call. |
| ImageSize | Host type | Width and height returned by png_size. |
Html methods
| Signature | Notes |
|---|---|
| Html.check_markdown(string) -> void | Check Markdown notes under a directory (the mdcheck command). |
| Html.diff(Doc, Doc) -> int | Structural difference count; ignores whitespace, comments, attribute order and data-* attributes. |
| Html.from_markdown(string) -> Doc | Markdown to document; the bool form allows raw HTML. |
| Html.from_markdown(string, bool) -> Doc | Markdown to document; the bool form allows raw HTML. |
| Html.index_markdown(string, string) -> string | Return generated index text for a notes directory (the index command). |
| Html.link_exists(Doc, string) -> bool | True when the internal destination exists. |
| Html.link_kind(Doc, string) -> string | Classify a link; kinds include external, special and outside-root. Nothing is fetched. |
| Html.load(string) -> Doc | Load one HTML file. |
| Html.load_dir(string) -> DocList | Load a directory of pages; the three-argument form adds include and exclude globs on relative paths. |
| Html.load_dir(string, string, string) -> DocList | Load a directory of pages; the three-argument form adds include and exclude globs on relative paths. |
| Html.parse(string) -> Doc | Parse 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) -> void | Atomic write confined to the working directory; honours --dry-run. |
| Html.save(string, string) -> void | Atomic write confined to the working directory; honours --dry-run. |
| Html.site(string, string, string) -> void | Build a static note site (the site command). |
| Html.write_template(DocList, int, string) -> int | Write shared subtrees with slot markers for pages sharing at least the given count. |
Doc methods
| Signature | Notes |
|---|---|
| Doc.byte_size() -> int | |
| Doc.classes_used() -> StrList | |
| Doc.clean(string) -> string | Main-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() -> string | Plain-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
| Signature | Notes |
|---|---|
| DocList.at(int) -> Doc | |
| DocList.classes_used() -> StrList | |
| DocList.css_classes() -> StrList | |
| DocList.css_ids() -> StrList | |
| DocList.ids() -> StrList | |
| DocList.len() -> int |
Node methods
| Signature | Notes |
|---|---|
| Node.append_html(string) -> Node | |
| Node.attr(string) -> string | |
| Node.attributes() -> StrList | |
| Node.get_attrs(StrList) -> StrMap | Fresh 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) -> Node | Bulk set; all names and values are validated before the first edit. |
| Node.tag() -> string | |
| Node.text() -> string |
NodeList methods
| Signature | Notes |
|---|---|
| NodeList.at(int) -> Node | |
| NodeList.len() -> int |
Report methods
| Signature | Notes |
|---|---|
| Report.add(string, string, int, string) -> void | |
| Report.fail_if_any() -> void | Marks the run failed when the report has entries. |
| Report.write_json(string) -> void | |
| Report.write_text(string) -> void |
ImageSize methods
| Signature | Notes |
|---|---|
| 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
| Group | Signatures |
|---|---|
| file | file_append(string, string) -> void; file_exists(string) -> bool; file_lines(string) -> StrList; file_read(string) -> string; file_write(string, string) -> void |
| constructors and json | float_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_return | lmcode_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 |
| math | math_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 |
| str | str_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
| Type | Methods |
|---|---|
| FloatList | add(float) -> FloatList; at(int) -> float; clear() -> FloatList; contains(float) -> bool; index_of(float) -> int; len() -> int; set(int, float) -> FloatList |
| FloatMap | clear() -> 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 |
| FloatPQ | clear() -> FloatPQ; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float, float) -> FloatPQ |
| FloatQueue | at(int) -> float; clear() -> FloatQueue; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float) -> FloatQueue |
| FloatStack | at(int) -> float; clear() -> FloatStack; empty() -> bool; len() -> int; peek() -> float; pop() -> float; push(float) -> FloatStack |
| IntList | add(int) -> IntList; at(int) -> int; clear() -> IntList; contains(int) -> bool; index_of(int) -> int; len() -> int; set(int, int) -> IntList |
| IntMap | clear() -> 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 |
| IntPQ | clear() -> IntPQ; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int, float) -> IntPQ |
| IntQueue | at(int) -> int; clear() -> IntQueue; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int) -> IntQueue |
| IntStack | at(int) -> int; clear() -> IntStack; empty() -> bool; len() -> int; peek() -> int; pop() -> int; push(int) -> IntStack |
| Json | as_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 |
| StrList | add(string) -> StrList; at(int) -> string; clear() -> StrList; contains(string) -> bool; index_of(string) -> int; join(string) -> string; len() -> int; set(int, string) -> StrList |
| StrMap | clear() -> 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 |
| StrPQ | clear() -> StrPQ; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string, float) -> StrPQ |
| StrQueue | at(int) -> string; clear() -> StrQueue; empty() -> bool; len() -> int; peek() -> string; pop() -> string; push(string) -> StrQueue |
| StrStack | at(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.
| Interface | Annotation | Role |
|---|---|---|
| RestGet | route path such as /health | Handles HTTP GET requests for the route. |
| RestPost | route path such as /health | Handles HTTP POST requests for the route. |
| RestPut | route path such as /health | Handles HTTP PUT requests for the route. |
| RestDelete | route path such as /health | Handles HTTP DELETE requests for the route. |
| RestPatch | route path such as /health | Handles HTTP PATCH requests for the route. |
| RestHead | route path such as /health | Handles HTTP HEAD requests for the route. |
| RestOptions | route path such as /health | Handles HTTP OPTIONS requests for the route. |
| RestHandler | route path | General route handler interface. |
| CliCommand | command name such as text | A stateless CLI command. |
| CliOption | option name such as --selector | A CLI option handler, run before the command. |
REST functions
| Signature | Notes |
|---|---|
| rest_cli(StrList) -> string | Stateless dispatch of options, commands and REST routes from an argument list; returns the response text. |
| rest_config(string, string) -> void | Set a configuration key, for example session to global. |
| rest_route(string, string, string) -> void | Register a route explicitly. |
| rest_serve() -> void | Serve the declared routes. |
| rest_stop() -> void | Stop 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.