Package atessera.publ

Class TexTranslator

java.lang.Object
atessera.publ.TexTranslator

public final class TexTranslator extends Object
Translates a PublicationContent into a compilable LaTeX document.

This is the primary translator for producing PDF output. It performs the following steps:

  1. Section translation — iterates over all sections of the publication and converts each one into a PublicationTemplate.Section according to its PublicationContent.SectionType:
    • MARKDOWN — parsed through the package-private Markdown renderer (which extends LatexTarget) 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 .pdf file to be produced by the compilation layer.
  2. Bibliography extraction — uses BiblioExtractor to scan all Markdown sections for BibItem nodes, collects them into a map, and sorts them alphabetically by the letters-and-digits content of their formatted text.
  3. Abstract processing — if the publication has an abstract section of type MARKDOWN, it is parsed and included before the main content.
  4. 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();
 
See Also:
  • Constructor Details

    • TexTranslator

      public TexTranslator(EngineFactory engineFactory, PublicationContent publ)
      Constructs a new translator.
      Parameters:
      engineFactory - the Velocity engine factory; must not be null
      publ - the publication content to translate; must not be null
      Throws:
      NullPointerException - if either argument is null
  • Method Details

    • translate

      public List<String> 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