Hide the wasm module.
parent
556afecbb8
commit
122adee23b
@ -0,0 +1,24 @@
|
||||
use crate::parser::parse_with_settings;
|
||||
use crate::settings::GlobalSettings;
|
||||
use crate::wasm::ParseResult;
|
||||
use crate::wasm::ToWasm;
|
||||
use crate::wasm::ToWasmContext;
|
||||
|
||||
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
||||
let rust_parsed = match parse_with_settings(org_contents, &GlobalSettings::default()) {
|
||||
Ok(document) => document,
|
||||
Err(err) => {
|
||||
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
||||
.unwrap();
|
||||
}
|
||||
};
|
||||
let to_wasm_context = ToWasmContext::new(org_contents);
|
||||
let wasm_document = match rust_parsed.to_wasm(to_wasm_context) {
|
||||
Ok(document) => document,
|
||||
Err(err) => {
|
||||
return serde_wasm_bindgen::to_value(&ParseResult::Error(format!("{:?}", err)))
|
||||
.unwrap();
|
||||
}
|
||||
};
|
||||
serde_wasm_bindgen::to_value(&ParseResult::Success(wasm_document)).unwrap()
|
||||
}
|
Loading…
Reference in New Issue