late2htm

Crates.iolate2htm
lib.rslate2htm
version0.1.0
created_at2025-06-02 12:51:24.104072+00
updated_at2025-06-02 12:51:24.104072+00
descriptionA Rust library for converting LaTeX-formatted text into HTML with minimal styling.
homepage
repositoryhttps://github.com/LunaStev/late2htm
max_upload_size
id1697928
size43,642
(LunaStev)

documentation

README

LaTeX to HTML

LaTeX to HTML is a Rust library that converts LaTeX-formatted text into equivalent HTML.

This crate is designed to help developers transform LaTeX documents or fragments into structured HTML. Styling is intentionally kept minimalโ€”developers are encouraged to apply custom CSS or integrate this library into a broader styling pipeline.


โœจ Features

  • โœ… Lightweight LaTeX parsing and conversion to HTML

  • โœ… Supports the following LaTeX commands:

    • Document structure: \section, \subsection, \subsubsection, \paragraph, \subparagraph
    • Text formatting: \textbf, \textit, \underline, \emph
    • Extended commands: \textcolor, \fontsize (planned)
    • Math mode: $...$, \[...\], \begin{equation} (planned)
    • Lists: itemize, enumerate, description (planned)
    • Tables: tabular (planned)
    • Figures: figure, \includegraphics (planned)
    • References and citations: \label, \ref, \cite, \footnote (planned)
    • Bibliography: thebibliography, \bibitem (planned)
    • Custom macros: \newcommand, \renewcommand (planned)
    • Fallback handler for unknown LaTeX commands: RawLatex

Note: Features marked (planned) are on the roadmap but not yet implemented.


๐Ÿš€ Usage

use late2htm::convert_latex_to_html;

fn main() {
    let latex_code = r"\\section{Hello}This is \\textbf{bold}.";
    let html = convert_latex_to_html(latex_code);
    println!("{}", html);
}

Additional Test Example

use late2htm::convert_latex_to_html;

fn main() {
    let input = r"\section{Main}\subsection{Sub}\subsubsection{SubSub}\paragraph{Para}\subparagraph{SubPara}Text \textbf{bold} and \textit{italic} and \underline{under} and \emph{emph}.";
    let html = convert_latex_to_html(input);
    println!("{}", html);
}

๐ŸŽ–๏ธ Crate Structure

  • parser โ€” Parses LaTeX code into an AST (LatexNode enum).
  • htmlgen โ€” Converts AST into HTML.
  • ast โ€” Defines the LaTeX abstract syntax tree (LatexNode).

๐ŸŽฏ Project Goals

  • ๐Ÿง  Simple and intuitive API for converting LaTeX to HTML
  • ๐Ÿงฉ Clean and semantic HTML output, ready for custom CSS
  • ๐Ÿ”Œ Modular architecture for easy feature extension
  • ๐Ÿ” Fallback support for unknown LaTeX commands (raw output)

๐Ÿ“œ License

This project is licensed under the MPL-2.0 License.


๐Ÿค Contributing

Contributions, issues, and feature requests are welcome! Feel free to fork and submit pull requests.

Commit count: 3

cargo fmt