Generate latex file from gnuplot This function generates a latex file with gnuplot `epslatex` backend and then source it into the generate latex function
(content: &str)
| 151 | /// This function generates a latex file with gnuplot `epslatex` backend and then source it into |
| 152 | /// the generate latex function |
| 153 | pub fn generate_latex_from_gnuplot(content: &str) -> Result<PathBuf> { |
| 154 | let path = Path::new(ART_PATH).join(hash(content)).with_extension("tex"); |
| 155 | |
| 156 | let gnuplot_path = which::which("gnuplot") |
| 157 | .map_err(Error::BinaryNotFound)?; |
| 158 | |
| 159 | let cmd = Command::new(gnuplot_path) |
| 160 | .stdin(Stdio::piped()) |
| 161 | .current_dir(ART_PATH) |
| 162 | .arg("-p") |
| 163 | .spawn() |
| 164 | .unwrap(); |
| 165 | //.expect("Could not spawn gnuplot"); |
| 166 | |
| 167 | let mut stdin = cmd.stdin.unwrap(); |
| 168 | |
| 169 | stdin |
| 170 | .write_all(format!("set output '{}'\n", path.file_name().unwrap().to_str().unwrap()).as_bytes()) |
| 171 | .map_err(Error::Io)?; |
| 172 | stdin |
| 173 | .write_all("set terminal epslatex color standalone\n".as_bytes()) |
| 174 | .map_err(Error::Io)?; |
| 175 | stdin |
| 176 | .write_all(content.as_bytes()) |
| 177 | .map_err(Error::Io)?; |
| 178 | |
| 179 | Ok(path) |
| 180 | } |
| 181 | |
| 182 | pub fn generate_latex_from_gnuplot_file(path: &Path) -> Result<PathBuf> { |
| 183 | let mut content = String::new(); |
no test coverage detected