Parse an equation with the given zoom
(
content: &str,
zoom: f32,
)
| 124 | |
| 125 | /// Parse an equation with the given zoom |
| 126 | pub fn parse_equation( |
| 127 | content: &str, |
| 128 | zoom: f32, |
| 129 | ) -> Result<PathBuf> { |
| 130 | let path = Path::new(ART_PATH).join(hash(content)).with_extension("svg"); |
| 131 | |
| 132 | // create a new tex file containing the equation |
| 133 | if !path.with_extension("tex").exists() { |
| 134 | let mut file = File::create(path.with_extension("tex")).map_err(Error::Io)?; |
| 135 | |
| 136 | file.write_all("\\documentclass[20pt, preview]{standalone}\n\\usepackage{amsmath}\\usepackage{amsfonts}\n\\begin{document}\n$$\n".as_bytes()) |
| 137 | .map_err(Error::Io)?; |
| 138 | |
| 139 | file.write_all(content.as_bytes()) |
| 140 | .map_err(Error::Io)?; |
| 141 | |
| 142 | file.write_all("$$\n\\end{document}".as_bytes()) |
| 143 | .map_err(Error::Io)?; |
| 144 | } |
| 145 | |
| 146 | generate_svg_from_latex(&path, zoom) |
| 147 | } |
| 148 | |
| 149 | /// Generate latex file from gnuplot |
| 150 | /// |
no test coverage detected