"""A KDE syntax definition for Mojo, for Pandoc and Quarto listings. Generated from the same harvested words as the editor's highlighter (corpus/tokens/tokens.json), so a printed listing and the Mojo pane colour the same words the same way: keywords, the ownership conventions, the postfix transfer ^, words 1.1.0 removed, decorators, and prelude names. Strings, including triple-quoted docstrings across lines, are their own contexts. """ from __future__ import annotations from xml.sax.saxutils import escape TRIPLE_DOUBLE = """"" TRIPLE_SINGLE = "'" * 3 def _items(words) -> str: return "\n".join(f" {escape(w)}" for w in words) def mojo_xml(version: str, repo: str, commit: str, keywords: list[str], conventions: list[str], removed: list[str], prelude: list[str], effects: list[str]) -> str: kw = sorted((set(keywords) - {"var", "ref"}) | set(effects)) # var and ref are coloured as conventions conv = sorted(set(conventions) | {"var", "ref"}) q = """ return f""" {_items(kw)} {_items(conv)} {_items(removed)} {_items(prelude)} """