@webority/markdown-core
v0.157.0
Published
The platform-neutral engine every Webority renderer and chat reads: the markdown grammar (block and inline parsing, the link rule and plain-text extraction) and, under ./chat, the assistant chat engine (server client, stream reader, wording and conversati
Readme
@webority/markdown-core
The one markdown grammar every Webority renderer reads. It turns a markdown string into blocks and
inline tokens, decides what a link may open, and extracts plain text. It draws nothing and touches
no platform API, so AppMarkdown (React), <wui-markdown> and <app-markdown> (Razor pages) and
the phone Markdown all draw the same document from the same rules.
| Export | What it does |
| --- | --- |
| parseMarkdown(source) | the blocks: paragraph, heading, list (nested by depth), table, code, quote, rule |
| parseInline(text, options?) | the inline tokens: text, code, strong, em, strike, link, image, citation |
| splitCitations(text, isCitation) | the plain text split at its [inner] runs: { text } parts and { citation } parts, a run isCitation rejects stays text |
| CITATION_RUN | the one citation pattern: [inner] not followed by (, inner non-empty with no bracket or line break |
| linkTarget(href, links, resolveLink, origin?, base?) | what a link opens: an app route, a page of this site (a relative address, or a web address on origin), a web address, a mail or phone address, or nothing. With base (an origin from linkBase) a relative address resolves against it first |
| linkBase(value) | the origin a relative link resolves against: an https origin with no path, query, fragment or credentials (a trailing / allowed), without it; anything else is null |
| webRoute(target) | the web route of a resolved app link |
| markdownToPlainText(source) | the text a screen reader, a preview or a search index reads |
| FigureRun | the type a figureText splitter returns: { kind: "text" \| "sub" \| "sup", text }; a sub or sup run draws lowered or raised |
links is "web" (open web, mail and phone addresses), "app" (open only what resolveLink
resolves to an in-app route) or "page". In "page" mode resolveLink is asked about every
address, and a relative address or a web address on origin draws as a page link; other web and
contact addresses stay text. Chat replies use "app", because model output must not send a
person off the app.
Citations are chat-only. parseInline(text, { isCitation }) reads an [inner] run that is not a
link as a citation token ({ type: "citation", text: inner }) when isCitation(inner) returns
true; without isCitation, no run is a citation. Citations are read inside bold, italics and strike,
never inside a link label or image alt text, and an escaped \[ is never a citation.
splitCitations applies the same rule to plain text for renderers that do not parse inline tokens.
