pub fn latex_to_svg(
latex_content: &str,
display: bool,
) -> Result<String, String>Expand description
Converts a LaTeX mathematical expression to SVG format.
This function takes a LaTeX expression string and renders it as an SVG image using the MicroTeX library. It supports both inline and display modes, which affects the size and spacing of the mathematical expression.
§Arguments
latex_content- The LaTeX mathematical expression to render (without delimiters)display- If true, uses display mode ($$…$$); if false, uses inline mode ($…$)
§Returns
Ok(String)- The SVG string representation of the rendered LaTeXErr(String)- An error message if rendering fails
§Examples
use markdown2pdf::latex::latex_to_svg;
// Inline math
let result = latex_to_svg("x^2 + y^2 = z^2", false);
assert!(result.is_ok());
// Display math (typically larger)
let result = latex_to_svg("\\int_0^\\infty e^{-x} dx", true);
assert!(result.is_ok());Note: Full LaTeX rendering examples are marked with ignore due to underlying
C++ dependencies that may cause crashes in test environments.