From b83e24e2f79b86b036fd8f612bdaa716d3849075 Mon Sep 17 00:00:00 2001 From: randogoth Date: Wed, 23 Sep 2026 09:27:49 +0300 Subject: [PATCH] Extract the WML exporter from md2txt into wapdown md2txt is a suite of minimal text-based markup exporters, and every other renderer in it (text, micron, ama, gemini, nex) is a straight transform of a document into a flat text format. The WML renderer is neither: it emits an XML tree, and it restructures the document rather than transforming it -- splitting one file into many s, inventing navigation between them, building a menu card that exists in no source document, and paginating on a byte budget. That is why it needed levers no sibling renderer needed, and why it alone forced a CARD_BREAK block kind and a {.card} directive into the shared parser that every other renderer ignores. wapdown is that renderer given a repository of its own, where restructuring a document into a navigable deck is the point. Ported: the Markdown parser, block event models, and pipeline core, each trimmed to what a deck compiler actually uses (no FIGlet, no hyphenation, no ASCII-art includes, no text-layout frontmatter), plus the eight inline regexes the renderer had been borrowing from a 1039-line text renderer. The plugin registry comes along so other WAP-era targets can register alongside wml later. Zero runtime dependencies. Config is now first-class: every lever is an argparse flag with validation and a frontmatter equivalent, layered CLI > frontmatter > default, replacing the generic --renderer-option KEY=VALUE passthrough. Five defects found while reading the code, each with a regression test: - Link and image URLs were shredded by the emphasis patterns, which ran before LINK_RE: a path like /v1_2_3/ became /v123/ inside the href. Links and images are now resolved and stashed first. - was emitted as a direct child of . The WML 1.3 content model is (onevent*, timer?, (do | p | pre)*), so it must sit in a

. - Link labels carried emphasis, but is declared (#PCDATA | br | img)* -- there is nowhere valid for a inside one. Markers are now stripped. - The menu card was built directly and never byte-packed, so the one card most likely to be large was the one card exempt from the budget. - Output was written with CRLF line endings. WML is XML served over HTTP. New, WAP-idiomatic rather than Markdown-idiomatic: - deck-level