Skip to content

Instantly share code, notes, and snippets.

@marcusbuffett
Last active October 6, 2019 18:52
Show Gist options
  • Save marcusbuffett/64f85576f0eb37199d1da3e47d3245e4 to your computer and use it in GitHub Desktop.
Save marcusbuffett/64f85576f0eb37199d1da3e47d3245e4 to your computer and use it in GitHub Desktop.
fn convert_to_html(input: &str) -> String {
let cmd = Command::new("pandoc")
.args(&["--from=markdown", "--to=html"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.expect("pandoc failed to start");
{
let mut pandoc_stdin = cmd.stdin.unwrap();
pandoc_stdin.write_all(& input.as_bytes());
}
// write!(pandoc_stdin, "# header").unwrap();
let mut pd_out_bytes = Vec::new();
// let mut stdout_out: [u8] = [];
println!("Gets here");
cmd.stdout.unwrap().read_to_end(&mut pd_out_bytes);
println!("Does not get here");
return String::from_utf8(pd_out_bytes).unwrap();
}
fn convert_to_html(input: &str) -> String {
let cmd = Command::new("pandoc")
.args(&["--from=markdown", "--to=html"])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.expect("pandoc failed to start");
let mut pandoc_stdin = cmd.stdin.unwrap();
write!(pandoc_stdin, "# header").unwrap();
let mut pd_out_bytes = Vec::new();
// let mut stdout_out: [u8] = [];
println!("Gets here");
cmd.stdout.unwrap().read_to_end(&mut pd_out_bytes);
println!("Does not get here");
return String::from_utf8(pd_out_bytes).unwrap();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment