text_and_tex2typst

Function text_and_tex2typst 

Source
pub fn text_and_tex2typst(input: &str) -> Result<String, String>
Expand description

Converts a given input string containing TeX math expressions to Typst format.

This function searches for inline and display math expressions within the input string, converts them to Typst format using the tex2typst function, and returns the resulting string.

§Arguments

  • input - A string slice that holds the input text containing TeX math expressions.

§Returns

  • Result<String, String> - On success, returns the converted string wrapped in Ok. On failure, returns an error message wrapped in Err.

§Errors

This function will return an error if the TeX to Typst conversion fails.

§Example

use tex2typst_rs::text_and_tex2typst;
let input = r"This is inline math: \(a + b\) and this is display math: \[a^2 + b^2 = c^2\]";
let output = text_and_tex2typst(input).unwrap();
println!("{}", output);