Crates.io | pandoc-wasm-wrapper |
lib.rs | pandoc-wasm-wrapper |
version | 0.2.0 |
source | src |
created_at | 2024-12-02 14:11:25.916703 |
updated_at | 2024-12-08 01:06:21.792647 |
description | Pandoc.wasm wrapper for easy deployment and a familiar interface |
homepage | |
repository | https://github.com/jcuenod/pandoc-wasm-wrapper |
max_upload_size | |
id | 1468703 |
size | 41,674 |
There are a few pandoc-related packages in the Rust ecosystem. All of them require pandoc as a separate dependency. This package wraps pandoc.wasm and uses wasmer to provide a pandoc binary that can be used in Rust without requiring pandoc to be installed on the system.
use pandoc_wasm_wrapper::pandoc;
#[tokio::main]
async fn main() {
let args: Vec<String> = vec![
"--from=markdown".to_string(),
"--to=html".to_string()
];
let input: Vec<u8> = "# Hello, world!".as_bytes().to_vec();
let output: String = pandoc(&args, &input).await.unwrap();
println!("{}", output);
}
If you wanted to convert a docx
to markdown
, you could do the following:
use pandoc_wasm_wrapper::pandoc;
#[tokio::main]
fn main() {
let args: Vec<String> = vec![
"--from=docx".to_string(),
"--to=markdown".to_string()
];
let docx_input: Vec<u8> = std::fs::read("path/to/file.docx").unwrap();
let md_output: String = pandoc(&args, &docx_input).await.unwrap();
println!("{}", md_output);
}
This package is completely dependent on the work of pandoc-wasm