Crate pulldown_latex

source ·
Expand description

This crate provides a pull Parser for LaTeX math notation, and a MathML renderer, available through the mathml module. This renderer closely follows the MathML Core specification.

§Usage

Rendering mathematical equations with pulldown-latex obviously begins with using the crate in order to generate the mathml markup. However, one also needs to include the stylesheet and fonts necessary to render the equations correctly and aesthetically.

§Including the Required Files

Files can be included in one of two ways, either by using a CDN or by downloading them from the release page and using them locally.

§Using a CDN

In the index.html file of your project, include the following lines:

<head>
    <!-- Rest of your HTML head -->
    <!-- ...................... -->
    
    <!-- Include the Stylesheet -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/carloskiki/pulldown-latex@{version}/styles.min.css">
    <!-- Include the Fonts -->
    <link rel="preload" href="https://cdn.jsdelivr.net/gh/carloskiki/pulldown-latex@{version}/font/" as="font" crossorigin="anonymous">
    
    <!-- Rest of your HTML head -->
    <!-- ...................... -->
</head>

Make sure to replace {version} with the version of the crate you are using or with latest if you want to use the latest version available.

§Using Local Files

Download the files from the GitHub releases page and include them in your project.

The styles.css file and the font directory should be placed together in the same directory. You can change this structure by modifying the paths in the styles.css file.

Modules§

  • Configuration options for the renderer.
  • The definition of the Event enum, which is used as a logical representation of LaTeX content.
  • A simple MathML Core renderer.
  • Contains the Parser, which Transforms input LaTeX into a stream of Result<Event, ParserError>.

Structs§

  • The parser completes the task of transforming the input LaTeX into a symbolic representation, namely a stream of Events.
  • Anything that could possibly go wrong while parsing.
  • Configuration for the mathml renderer.
  • This storage is used by the parser to store the expaned content of a macro call. It is only used when user-defined macros are used. Otherwise, this storage is not used and is zero-overhead.

Enums§

  • All events that can be produced by the parser.

Functions§

  • Takes a Parser, or any Iterator<Item = Result<Event<'_>, E>> as input, and renders the MathML into the given string.
  • Takes a Parser, or any Iterator<Item = Result<Event<'_>, E>>, as input and renders the MathML into the given writer.