MCPcopy Create free account
hub / github.com/bytesnake/vim-graphical-preview / parse_latex

Function parse_latex

src/utils.rs:193–211  ·  view source on GitHub ↗

Parse a latex content and convert it to a SVG file

(
    content: &str,
)

Source from the content-addressed store, hash-verified

191
192/// Parse a latex content and convert it to a SVG file
193pub fn parse_latex(
194 content: &str,
195) -> Result<PathBuf> {
196 let path = Path::new(ART_PATH).join(hash(content)).with_extension("svg");
197
198 // create a new tex file containing the equation
199 if !path.with_extension("tex").exists() {
200 let mut file = File::create(&path.with_extension("tex")).map_err(Error::Io)?;
201
202 file.write_all(content.as_bytes())
203 .map_err(Error::Io)?;
204 }
205
206 if !path.exists() {
207 generate_svg_from_latex(&path, 1.0)?;
208 }
209
210 Ok(path)
211}
212
213pub fn parse_latex_from_file(
214 path: &Path,

Callers 2

parse_latex_from_fileFunction · 0.85
generateMethod · 0.85

Calls 2

hashFunction · 0.85
generate_svg_from_latexFunction · 0.85

Tested by

no test coverage detected