Separate out rust parsing step to support references to values stored in the parsed state.
Some checks failed
clippy Build clippy has failed
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded

This commit is contained in:
Tom Alexander 2023-12-27 12:20:58 -05:00
parent 1812b1a56e
commit 36b80dc093
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
63 changed files with 88 additions and 90 deletions

View File

@ -1,10 +1,28 @@
use organic::wasm::wasm_parse_org;
use organic::parser::parse_with_settings;
use organic::settings::GlobalSettings;
use organic::wasm::ParseResult;
use organic::wasm::ToWasm;
use organic::wasm::ToWasmContext;
use wasm_bindgen::prelude::wasm_bindgen;
#[wasm_bindgen]
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
let rust_parsed = wasm_parse_org(org_contents);
serde_wasm_bindgen::to_value(&rust_parsed).unwrap()
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()
}
fn main() -> Result<(), Box<dyn std::error::Error>> {

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmAngleLink<'s, 'p> {
pub struct WasmAngleLink<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmBabelCall<'s, 'p> {
pub struct WasmBabelCall<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmBold<'s, 'p> {
pub struct WasmBold<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmCenterBlock<'s, 'p> {
pub struct WasmCenterBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmCitation<'s, 'p> {
pub struct WasmCitation<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmCitationReference<'s, 'p> {
pub struct WasmCitationReference<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmClock<'s, 'p> {
pub struct WasmClock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmCode<'s, 'p> {
pub struct WasmCode<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmComment<'s, 'p> {
pub struct WasmComment<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmCommentBlock<'s, 'p> {
pub struct WasmCommentBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDiarySexp<'s, 'p> {
pub struct WasmDiarySexp<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -46,12 +46,12 @@ to_wasm!(
.map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_>>::into)
.map(Into::<WasmAstNode<'_, '_>>::into)
})
.chain(original.children.iter().map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_>>::into)
.map(Into::<WasmAstNode<'_, '_>>::into)
}))
.collect::<Result<Vec<_>, _>>()?;

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDrawer<'s, 'p> {
pub struct WasmDrawer<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDynamicBlock<'s, 'p> {
pub struct WasmDynamicBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmEntity<'s, 'p> {
pub struct WasmEntity<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmExampleBlock<'s, 'p> {
pub struct WasmExampleBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmExportBlock<'s, 'p> {
pub struct WasmExportBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmExportSnippet<'s, 'p> {
pub struct WasmExportSnippet<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmFixedWidthArea<'s, 'p> {
pub struct WasmFixedWidthArea<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmFootnoteDefinition<'s, 'p> {
pub struct WasmFootnoteDefinition<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmFootnoteReference<'s, 'p> {
pub struct WasmFootnoteReference<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "headline")]
pub(crate) struct WasmHeadline<'s, 'p> {
pub struct WasmHeadline<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmHorizontalRule<'s, 'p> {
pub struct WasmHorizontalRule<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmInlineBabelCall<'s, 'p> {
pub struct WasmInlineBabelCall<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmInlineSourceBlock<'s, 'p> {
pub struct WasmInlineSourceBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmItalic<'s, 'p> {
pub struct WasmItalic<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmKeyword<'s, 'p> {
pub struct WasmKeyword<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmLatexEnvironment<'s, 'p> {
pub struct WasmLatexEnvironment<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmLatexFragment<'s, 'p> {
pub struct WasmLatexFragment<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmLineBreak<'s, 'p> {
pub struct WasmLineBreak<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -3,11 +3,11 @@
/// This exists to make changing the type signature easier.
macro_rules! to_wasm {
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => {
impl<'s, 'p> ToWasm for $istruct {
impl<'s, 'p> ToWasm<'p> for $istruct {
type Output = $ostruct;
fn to_wasm(
&self,
&'p self,
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> {
let $original = self;

View File

@ -64,7 +64,6 @@ mod verse_block;
pub use ast_node::WasmAstNode;
pub use document::WasmDocument;
pub use parse_result::wasm_parse_org;
pub use parse_result::ParseResult;
pub(crate) use to_wasm::ToWasm;
pub(crate) use to_wasm::ToWasmContext;
pub use to_wasm::ToWasm;
pub use to_wasm::ToWasmContext;

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmNodeProperty<'s, 'p> {
pub struct WasmNodeProperty<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmOrgMacro<'s, 'p> {
pub struct WasmOrgMacro<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmParagraph<'s, 'p> {
pub struct WasmParagraph<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -1,10 +1,6 @@
use serde::Serialize;
use super::document::WasmDocument;
use super::ToWasm;
use super::ToWasmContext;
use crate::parser::parse_with_settings;
use crate::settings::GlobalSettings;
#[derive(Debug, Serialize)]
#[serde(tag = "status", content = "content")]
@ -15,18 +11,3 @@ pub enum ParseResult<'s, 'p> {
#[serde(rename = "error")]
Error(String),
}
pub fn wasm_parse_org(org_contents: &str) -> ParseResult<'_, '_> {
let global_settings = GlobalSettings::default();
let to_wasm_context = ToWasmContext::new(org_contents);
let rust_parsed = match parse_with_settings(org_contents, &global_settings)
.map(|document| document.to_wasm(to_wasm_context))
.map(|wasm_document| match wasm_document {
Ok(wasm_document) => ParseResult::Success(wasm_document),
Err(err) => ParseResult::Error(format!("{:?}", err)),
}) {
Ok(wasm_document) => wasm_document,
Err(err) => ParseResult::Error(format!("{:?}", err)),
};
rust_parsed
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmPlainLink<'s, 'p> {
pub struct WasmPlainLink<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmPlainList<'s, 'p> {
pub struct WasmPlainList<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmPlainListItem<'s, 'p> {
pub struct WasmPlainListItem<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmPlainText<'s, 'p> {
pub struct WasmPlainText<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmPlanning<'s, 'p> {
pub struct WasmPlanning<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmPropertyDrawer<'s, 'p> {
pub struct WasmPropertyDrawer<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmQuoteBlock<'s, 'p> {
pub struct WasmQuoteBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmRadioLink<'s, 'p> {
pub struct WasmRadioLink<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmRadioTarget<'s, 'p> {
pub struct WasmRadioTarget<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmRegularLink<'s, 'p> {
pub struct WasmRegularLink<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "section")]
pub(crate) struct WasmSection<'s, 'p> {
pub struct WasmSection<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmSpecialBlock<'s, 'p> {
pub struct WasmSpecialBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmSrcBlock<'s, 'p> {
pub struct WasmSrcBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmStatisticsCookie<'s, 'p> {
pub struct WasmStatisticsCookie<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmStrikeThrough<'s, 'p> {
pub struct WasmStrikeThrough<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmSubscript<'s, 'p> {
pub struct WasmSubscript<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmSuperscript<'s, 'p> {
pub struct WasmSuperscript<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmTable<'s, 'p> {
pub struct WasmTable<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmTableCell<'s, 'p> {
pub struct WasmTableCell<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmTableRow<'s, 'p> {
pub struct WasmTableRow<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmTarget<'s, 'p> {
pub struct WasmTarget<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmTimestamp<'s, 'p> {
pub struct WasmTimestamp<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -1,9 +1,9 @@
use crate::error::CustomError;
pub(crate) trait ToWasm {
pub trait ToWasm<'p> {
type Output;
fn to_wasm(&self, full_document: ToWasmContext<'_>) -> Result<Self::Output, CustomError>;
fn to_wasm(&'p self, full_document: ToWasmContext<'_>) -> Result<Self::Output, CustomError>;
}
pub(crate) trait ToWasmStandardProperties {
@ -16,12 +16,12 @@ pub(crate) trait ToWasmStandardProperties {
}
#[derive(Debug, Clone)]
pub(crate) struct ToWasmContext<'s> {
pub struct ToWasmContext<'s> {
pub(crate) full_document: &'s str,
}
impl<'s> ToWasmContext<'s> {
pub(crate) fn new(full_document: &'s str) -> ToWasmContext<'s> {
pub fn new(full_document: &'s str) -> ToWasmContext<'s> {
ToWasmContext { full_document }
}
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmUnderline<'s, 'p> {
pub struct WasmUnderline<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmVerbatim<'s, 'p> {
pub struct WasmVerbatim<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}

View File

@ -10,7 +10,7 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmVerseBlock<'s, 'p> {
pub struct WasmVerseBlock<'s, 'p> {
standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>,
}