Litexml authoring

From Innei/haklex · View interactive version

Litexml authoring is an AI agent skill from the GitHub repository Innei/haklex. Use when writing Haklex articles with Markdown plus LiteXML, choosing the appropriate Haklex node for content, authoring LiteXML fragments, or converting a LightXML/LiteXML string or file into Lexical SerializedEditorState JSON, Markdown, or Static Render HTML via the `litexml` CLI.

How to use this skill

Skill file

LiteXML Authoring

Use this skill when an article needs Haklex-specific rich nodes, or when the user asks to convert LiteXML to Lexical JSON / Markdown / HTML via the litexml CLI.

The skill is split into a thin index (this file) plus per-topic references. Load the matching reference when you start the actual work — the index is intentionally short so the format decision table and node selection map fit in one read.

References

| File | When to load |

| ---------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |

| CODE0 | Running the litexml binary — every flag, every input/output mode, every runtime caveat. |

| CODE0 | Authoring with structural tags (<p>, headings, lists, tables, links) and inline formatting (<b>, <em>, <code>, …). |

| CODE0 | Authoring with Haklex extension tags (media, code, math, callouts, containers, footnotes, chat, poll, …). |

| CODE0 | CDATA usage, block IDs, nested-content rules, similar-node disambiguation, validation, adding new nodes. |

packages/rich-editor/docs/markdown-flavor-litexml.md is the canonical tag contract — read it before changing any tag name or attribute schema.

Format decision

| Content requirement | Use |

| ----------------------------------------------------------------------- | ----------------------------------------------------------------- |

| Plain prose, headings, simple links, lists, quotes, tables, code fences | Markdown |

| Any Haklex extension tag is required | LiteXML — for the whole fragment, including surrounding prose |

| A block needs stable identity for later edits | LiteXML with id="..." (maps to $.blockId) |

| Fresh poll/chat content | LiteXML without IDs — the reader mints them |

Once a fragment contains any LiteXML tag, all surrounding prose in that fragment must also be LiteXML. Markdown is not parsed inside a LiteXML fragment.

Hard rule — no Markdown tokens inside LiteXML. **bold**, *italic*, ` code , # heading, - item, text inside any <p>/<li>/<h> are emitted as literal characters. Use <b>, <i>, <code>, <h2>, <ul><li><p>, <a href> instead. Before returning a LiteXML fragment, scan it for *, `, and line-leading #/-/1.` and convert them.

<!-- wrong -->
<p>Run **npm install** then see `README.md`</p>
<!-- right -->
<p>Run <b>npm install</b> then see <code>README.md</code></p>

CLI quick start

# inside the haklex monorepo
pnpm --silent litexml input.xml --format json --compact # → SerializedEditorState
pnpm --silent litexml input.xml --format markdown       # → Markdown
pnpm --silent litexml input.xml --format html --open    # → HTML preview, browser

# outside the monorepo
npx --yes -p @haklex/rich-litexml-cli litexml input.xml --format json

Full flag reference, output forms, theme/variant/lang options, error modes, validation pipelines: CODE0.

Node selection map

Detailed When / Avoid when / params / body rules for each tag live in CODE2 and CODE3. Use this table only to decide which reference to open.

| Need | Tag | Reference |

| ------------------------------------------------------ | --------------------------------------------------------------------------- | ---------- |

| Paragraph, heading, list, table, link, inline format | <p> / <h*> / <ul> / <ol> / <table> / <a> / <b> / <code> / … | structural |

| Quote (with optional attribution) | <blockquote> | structural |

| Single image / multi-image / video / embed / link card | <img> / <gallery> / <video> / <embed> / <link-card> | extensions |

| Downloadable file attachment | <attachment> | extensions |

| Code (single / multi-file) | <codeblock> / <code-snippet> | extensions |

| Diagram (Mermaid / whiteboard scene) | <mermaid> / <excalidraw> | extensions |

| Data chart (bar / line / area / pie / scatter) | <chart> | extensions |

| Numbered procedure with titled steps | <steps> + <step> | extensions |

| Math (inline / block) | <math> / <math display="block"> | extensions |

| Callout (semantic / page-wide) | <alert> / <banner> | extensions |

| Collapsible / nested doc / multi-column | <details> / <nested-doc> / <grid><cell> | extensions |

| Inline annotation | <spoiler> / <ruby> / <mention> / <tag> / <comment> | extensions |

| Footnote | <footnote> + <footnote-section> | extensions |

| Chat / poll | <chat> / <poll> | extensions |

| Remote interactive component (host catalog only) | <dynamic> | extensions |

| Internal review marker | <agent-diff> | extensions |

Cross-cutting rules

Details, gotchas, and the full disambiguation matrix: CODE0.

Validation

After producing or editing LiteXML, round-trip to compact JSON to confirm the registry parses every tag:

pnpm --silent litexml '<doc><p>Hello</p></doc>' --format json --compact

If the command succeeds but a downstream editor cannot materialize a node, the runtime is missing that Haklex node class — re-check the consumer's nodes registration, not the CLI.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.