Crate tylax

Crate tylax 

Source
Expand description

§tylax

High-performance bidirectional LaTeX ↔ Typst converter written in Rust.

§Features

  • High Performance: AST-based parsing engine built on Rust
  • Bidirectional: Supports both LaTeX → Typst and Typst → LaTeX
  • Full Document: Converts complete documents including headings, lists, tables
  • Rich Symbol Set: 700+ symbol mappings
  • WASM Support: Compiles to WebAssembly for browser usage
  • Table Support: Full table conversion with multicolumn/multirow
  • Reference System: Complete citation and cross-reference support
  • Macro Expansion: Basic LaTeX macro definition and expansion

§Usage Examples

§Math Formula Conversion

use tylax::{latex_to_typst, typst_to_latex};

// LaTeX → Typst
let typst = latex_to_typst(r"\frac{1}{2}");
assert!(typst.contains("frac") || typst.contains("/"));

// Typst → LaTeX
let latex = typst_to_latex("frac(1, 2)");
assert!(latex.contains(r"\frac"));

§Full Document Conversion

use tylax::{latex_document_to_typst, typst_document_to_latex};

let typst = latex_document_to_typst(r#"
    \documentclass{article}
    \title{My Paper}
    \begin{document}
    \section{Introduction}
    Hello, world!
    \end{document}
"#);

let latex = typst_document_to_latex(r#"
    = Introduction
     
    Hello, *world*!
"#);

Re-exports§

pub use core::typst2latex;
pub use core::typst2latex::T2LOptions;
pub use core::typst2latex::typst_document_to_latex;
pub use core::typst2latex::typst_to_latex;
pub use core::typst2latex::typst_to_latex_with_options;
pub use core::latex2typst::convert_document_with_ast;
pub use core::latex2typst::convert_document_with_ast_options;
pub use core::latex2typst::convert_math_with_ast;
pub use core::latex2typst::convert_math_with_ast_options;
pub use core::latex2typst::convert_with_ast;
pub use core::latex2typst::convert_with_ast_options;
pub use core::latex2typst::ConversionMode;
pub use core::latex2typst::ConversionState;
pub use core::latex2typst::EnvironmentContext;
pub use core::latex2typst::L2TOptions;
pub use core::latex2typst::LatexConverter;
pub use data::constants;
pub use data::maps;
pub use features::bibtex;
pub use features::images;
pub use features::macros;
pub use features::refs;
pub use features::tables;
pub use features::templates;
pub use features::tikz;
pub use data::colors;
pub use data::extended_symbols;
pub use data::siunitx;
pub use data::symbols;
pub use utils::diagnostics;
pub use utils::error::ConversionError;
pub use utils::error::ConversionOutput;
pub use utils::error::ConversionResult;
pub use utils::error::ConversionWarning;
pub use utils::files;

Modules§

core
Core conversion modules Core conversion modules
data
Data layer - static mappings and constants Data layer - Static mappings and constants
features
Feature modules - advanced conversion features Feature modules - Advanced conversion features
utils
Utility modules Utility modules

Functions§

convert_auto
Convert with automatic direction detection
convert_auto_document
Convert with automatic direction detection for full documents
detect_format
Detect input format
latex_document_to_typst
Convert a complete LaTeX document to Typst
latex_document_to_typst_with_options
Convert a complete LaTeX document to Typst with custom options
latex_to_typst
Convert LaTeX math code to Typst math code
latex_to_typst_with_options
Convert LaTeX math code to Typst math code with custom options