Package atessera.publ
Class TexTranslator
java.lang.Object
atessera.publ.TexTranslator
Translates a
PublicationContent into a compilable LaTeX document.
This is the primary translator for producing PDF output. It performs the following steps:
- Section translation — iterates over all
sections of the publication and converts each one into a
PublicationTemplate.Sectionaccording to itsPublicationContent.SectionType:MARKDOWN— parsed through the package-privateMarkdownrenderer (which extendsLatexTarget) and converted to LaTeX.LATEX— passed through unchanged.LISTING— wrapped as a source code listing with a file reference, label, caption, and language hint.EQUATION— wrapped as a numbered equation with an optional label.PLANTUML,METAPOST,GNUPLOT,GRAPHVIZ_DOT— treated as images; the translator expects a corresponding.pdffile to be produced by the compilation layer.
- Bibliography extraction — uses
BiblioExtractorto scan all Markdown sections forBibItemnodes, collects them into a map, and sorts them alphabetically by the letters-and-digits content of their formatted text. - Abstract processing — if the publication
has an abstract section of type
MARKDOWN, it is parsed and included before the main content. - Template assembly — all collected data is
fed into a
PublicationTemplate, which renders the final LaTeX source via Apache Velocity.
Thread safety
Instances of this class are not thread-safe. Each translation should use its own instance.
Typical usage
EngineFactory factory = new EngineFactory(templates);
PublicationContent content = PublicationContent.fromJson(jsonString);
TexTranslator translator = new TexTranslator(factory, content);
List<String> latexSource = translator.translate();
-
Constructor Summary
ConstructorsConstructorDescriptionTexTranslator(EngineFactory engineFactory, PublicationContent publ) Constructs a new translator. -
Method Summary
-
Constructor Details
-
TexTranslator
Constructs a new translator.- Parameters:
engineFactory- the Velocity engine factory; must not benullpubl- the publication content to translate; must not benull- Throws:
NullPointerException- if either argument isnull
-
-
Method Details
-
translate
Performs the full translation and returns the resulting LaTeX source as a list of lines.This method orchestrates section translation, bibliography extraction, abstract processing, and final template rendering.
- Returns:
- the generated LaTeX source, one string per line; never
null - Throws:
IllegalStateException- if the abstract section has an unsupported type
-