Parse a latex content and convert it to a SVG file
(
content: &str,
)
| 191 | |
| 192 | /// Parse a latex content and convert it to a SVG file |
| 193 | pub 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 | |
| 213 | pub fn parse_latex_from_file( |
| 214 | path: &Path, |
no test coverage detected