Package atessera.util


package atessera.util
Provides general-purpose utility classes used throughout Alpha Tessera Base.

This package contains low-level helpers for shell command execution, temporary directory management, text file I/O, LaTeX string escaping, random identifier generation, and SVG math rendering. These utilities are used by the compilation (atessera.comp), templating (atessera.templ), and Markdown processing (atessera.markdown) subsystems.

Key classes

ShellCmd
Executes a shell command via /bin/bash -c in a specified working directory. Captures standard output and error streams in separate threads. Provides both instance-level (waitFor()) and static (execAndWait()) methods for synchronous execution.
TempDir
Creates and manages a temporary directory. Implements AutoCloseable so the directory and all its contents are recursively deleted when the try-with-resources block exits. Provides convenience methods for executing shell commands within the temporary directory.
TextUtils
Static helpers for reading and writing text files, reading Java resources, and processing line-based configuration files (skipping comments and empty lines, converting to uppercase).
LatexUtils
Static methods for escaping text for LaTeX output. Three levels of escaping are provided:
  • escape(String) — full escaping of all special characters including ~ and ".
  • escapeStrict(String) — strict escaping with additional handling for -, <, >, ', `, ^, and ~.
  • escapeRelaxed(String) — relaxed escaping that leaves ~ unescaped (suitable for LaTeX arguments where tilde has its normal meaning).
IdStr
Generates random identifier strings of a specified length using SecureRandom. Only alphanumeric characters and underscores are used. Provides a static convenience method getRandomId(int) backed by a singleton instance.
SvgGenerator
Converts LaTeX math expressions to SVG images using the latex and dvisvgm command-line tools. Supports configurable temporary directories, SVG scaling, and unique ID generation for multiple formulas on the same page. Provides a checkDependencies() method to verify that the required tools are available.

Usage notes

All classes in this package are stateless or have minimal mutable state, making them suitable for use across multiple threads with appropriate external synchronization where needed (e.g. SvgGenerator uses synchronized on the generateSvg method to serialize formula counter access).

See Also: