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

Function parse_equation

src/utils.rs:126–147  ·  view source on GitHub ↗

Parse an equation with the given zoom

(
    content: &str,
    zoom: f32,
)

Source from the content-addressed store, hash-verified

124
125/// Parse an equation with the given zoom
126pub 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///

Callers 1

generateMethod · 0.85

Calls 2

hashFunction · 0.85
generate_svg_from_latexFunction · 0.85

Tested by

no test coverage detected