Package atessera.markdown
package atessera.markdown
Provides the Markdown processing subsystem for Alpha Tessera Base.
This package extends the commonmark-java
library with custom AST nodes, block parsers, inline link processors,
and renderers that target both LaTeX and HTML output. It is the core
of the text-to-document pipeline, sitting between the raw Markdown
input and the format-specific translators in atessera.publ.
Architecture
The package is organized into several subpackages, each handling a distinct concern:
blocks- Custom AST node types that extend commonmark-java's
CustomBlockandCustomNode. These represent domain-specific constructs such as bibliography items, labels, math expressions, cross-references, citations, and advanced images. parsers- Custom
BlockParserFactoryimplementations that recognize the extended syntax (e.g.*** [#key],@@ label @@,> [||] caption) and produce the correspondingatessera.markdown.blocksnodes. renderers- Custom
NodeRendererimplementations that convert the extended AST nodes into LaTeX or HTML output. These are the rendering backends used byLatexTargetandHtmlTarget. tex- A standalone LaTeX rendering pipeline (independent of
commonmark-java's built-in renderers). Includes
TexRenderer(the top-level renderer),CoreRenderer(handles standard Markdown nodes), andTexWriter(buffered output with LaTeX-specific conveniences). cust- Customized inline parsing infrastructure. Includes a modified
InlineParserImplthat extends commonmark-java's inline parser with support for additional delimiter processors and link markers, and aStaggeredDelimiterProcessorthat dispatches delimiter runs to multiple processors based on run length.
Key top-level classes
LatexTarget- Configurable Markdown-to-LaTeX pipeline. Wraps a
Parserand aTexRenderer, with feature flags to enable citations, labels, math, references, and advanced images. Provides convenience methodsparse(String)andparse(List<String>). HtmlTarget- Configurable Markdown-to-HTML pipeline. Wraps a
Parserand an HTML renderer with feature flags for extended character processing, citations, labels, math, references, and advanced images. Supports splitting output at chapter boundaries and translating references viaRefTranslation. Renderers- Interface defining the contract for rendering all custom AST
node types. Implemented by
RenderersBase(provides defaulttoString()-based rendering) and overridden by domain-specific targets. EnumNodes- A utility for depth-first traversal of the AST, applying a
Consumerto every node. Used extensively for collecting bibliography items and citation definitions after parsing.
Link processors
Several LinkProcessor implementations intercept inline link syntax
([text]) and reinterpret it based on the text prefix:
MathLinkProcessor— text starting with$becomes inline math (MathDefinition).RefLinkProcessor— text starting with@becomes a cross-reference (Reference); double@@denotes a page reference.CiteLinkProcessor— text starting with#becomes a citation (CiteReference).
Data flow
Markdown text
│
▼
LatexTarget / HtmlTarget
│
├──► Parser (commonmark-java + custom block parsers + link processors)
│
▼
AST (commonmark nodes + custom blocks/nodes from atessera.markdown.blocks)
│
▼
Renderer (CoreRenderer + TexNodeRenderer / HtmlNodeRenderer)
│
▼
LaTeX / HTML output
-
ClassDescriptionSaves the information about a translated reference for future title generation or JavaScript integration.