Compare commits

...

10 Commits

Author SHA1 Message Date
Tom Alexander
e622d9fa6b
Remove the old implementation of print_versions.
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
2023-12-26 19:15:02 -05:00
Tom Alexander
8186fbb8b3
Move print_versions into a util crate. 2023-12-26 19:06:12 -05:00
Tom Alexander
68ccff74fa
Outline for the wasm compare function. 2023-12-26 18:55:28 -05:00
Tom Alexander
9a13cb72c6
Make the wasm test binary async. 2023-12-25 14:32:01 -05:00
Tom Alexander
65abaa332f
Separate out the wasm test into its own feature/binary. 2023-12-25 13:12:32 -05:00
Tom Alexander
67e5829fd9
Populating document's children. 2023-12-25 12:55:48 -05:00
Tom Alexander
995b41e697
Remove deserialize to support borrows. 2023-12-25 12:42:38 -05:00
Tom Alexander
eb51bdfe2f
Add original field name to wasm macro. 2023-12-25 12:32:35 -05:00
Tom Alexander
bbb9ec637a
Add code to test the wasm code path without actually dropping into wasm. 2023-12-25 12:14:50 -05:00
Tom Alexander
dc012b49f5
Add a generic WasmAstNode enum. 2023-12-25 11:51:39 -05:00
74 changed files with 804 additions and 423 deletions

View File

@ -44,6 +44,11 @@ path = "src/lib.rs"
path = "src/bin_wasm.rs" path = "src/bin_wasm.rs"
required-features = ["wasm"] required-features = ["wasm"]
[[bin]]
name = "wasm_test"
path = "src/bin_wasm_test.rs"
required-features = ["wasm_test"]
[dependencies] [dependencies]
futures = { version = "0.3.28", optional = true } futures = { version = "0.3.28", optional = true }
nom = "7.1.1" nom = "7.1.1"
@ -52,6 +57,7 @@ opentelemetry-otlp = { version = "0.13.0", optional = true }
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true } opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
serde = { version = "1.0.193", optional = true, features = ["derive"] } serde = { version = "1.0.193", optional = true, features = ["derive"] }
serde-wasm-bindgen = { version = "0.6.3", optional = true } serde-wasm-bindgen = { version = "0.6.3", optional = true }
serde_json = { version = "1.0.108", optional = true }
tokio = { version = "1.30.0", optional = true, default-features = false, features = ["rt", "rt-multi-thread"] } tokio = { version = "1.30.0", optional = true, default-features = false, features = ["rt", "rt-multi-thread"] }
tracing = { version = "0.1.37", optional = true } tracing = { version = "0.1.37", optional = true }
tracing-opentelemetry = { version = "0.20.0", optional = true } tracing-opentelemetry = { version = "0.20.0", optional = true }
@ -69,6 +75,7 @@ foreign_document_test = ["compare", "dep:futures", "tokio/sync", "dep:walkdir",
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"] tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
event_count = [] event_count = []
wasm = ["dep:serde", "dep:wasm-bindgen", "dep:serde-wasm-bindgen"] wasm = ["dep:serde", "dep:wasm-bindgen", "dep:serde-wasm-bindgen"]
wasm_test = ["wasm", "dep:serde_json", "tokio/process", "tokio/macros"]
# Optimized build for any sort of release. # Optimized build for any sort of release.
[profile.release-lto] [profile.release-lto]

View File

@ -34,6 +34,10 @@ wasm:
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm > cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
> wasm-bindgen --target web --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm > wasm-bindgen --target web --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm
.PHONY: run_wasm
run_wasm:
> cat /tmp/test.org | cargo run --profile wasm --bin wasm_test --features wasm_test | jq
.PHONY: clean .PHONY: clean
clean: clean:
> cargo clean > cargo clean

View File

@ -1,3 +1,4 @@
#![feature(exit_status_error)]
#![feature(round_char_boundary)] #![feature(round_char_boundary)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
use std::io::Read; use std::io::Read;
@ -5,6 +6,8 @@ use std::io::Read;
use organic::compare::run_anonymous_compare; use organic::compare::run_anonymous_compare;
use organic::compare::run_compare_on_file; use organic::compare::run_compare_on_file;
mod util;
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]
use crate::init_tracing::init_telemetry; use crate::init_tracing::init_telemetry;
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]

View File

@ -1,10 +1,6 @@
#![no_main] #![no_main]
use organic::parser::parse_with_settings; use wasm::wasm_parse_org;
use organic::settings::GlobalSettings;
use wasm::ParseResult;
use wasm::ToWasm;
use wasm::ToWasmContext;
use wasm_bindgen::prelude::wasm_bindgen; use wasm_bindgen::prelude::wasm_bindgen;
mod error; mod error;
@ -12,16 +8,6 @@ mod wasm;
#[wasm_bindgen] #[wasm_bindgen]
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue { pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
let global_settings = GlobalSettings::default(); let rust_parsed = wasm_parse_org(org_contents);
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)),
};
serde_wasm_bindgen::to_value(&rust_parsed).unwrap() serde_wasm_bindgen::to_value(&rust_parsed).unwrap()
} }

72
src/bin_wasm_test.rs Normal file
View File

@ -0,0 +1,72 @@
#![feature(exact_size_is_empty)]
#![feature(exit_status_error)]
use std::io::Read;
use organic::settings::GlobalSettings;
use wasm::wasm_parse_org;
mod error;
mod util;
mod wasm;
#[cfg(feature = "tracing")]
use crate::init_tracing::init_telemetry;
#[cfg(feature = "tracing")]
use crate::init_tracing::shutdown_telemetry;
use crate::wasm::compare::wasm_run_anonymous_compare_with_settings;
#[cfg(feature = "tracing")]
mod init_tracing;
#[cfg(not(feature = "tracing"))]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(async {
let main_body_result = main_body().await;
main_body_result
})
}
#[cfg(feature = "tracing")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let rt = tokio::runtime::Runtime::new()?;
rt.block_on(async {
init_telemetry()?;
let main_body_result = main_body().await;
shutdown_telemetry()?;
main_body_result
})
}
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
let args = std::env::args().skip(1);
if args.is_empty() {
let org_contents = read_stdin_to_string()?;
let wasm_result = wasm_parse_org(org_contents.as_str());
println!("{}", serde_json::to_string(&wasm_result)?);
if wasm_run_anonymous_compare_with_settings(org_contents, &GlobalSettings::default(), false)
.await?
{
} else {
Err("Diff results do not match.")?;
}
Ok(())
} else {
todo!()
// for arg in args {
// if run_compare_on_file(arg).await? {
// } else {
// Err("Diff results do not match.")?;
// }
// }
// Ok(())
}
}
fn read_stdin_to_string() -> Result<String, Box<dyn std::error::Error>> {
let mut stdin_contents = String::new();
std::io::stdin()
.lock()
.read_to_string(&mut stdin_contents)?;
Ok(stdin_contents)
}

View File

@ -4,13 +4,12 @@ use crate::compare::diff::compare_document;
use crate::compare::diff::DiffResult; use crate::compare::diff::DiffResult;
use crate::compare::parse::emacs_parse_anonymous_org_document; use crate::compare::parse::emacs_parse_anonymous_org_document;
use crate::compare::parse::emacs_parse_file_org_document; use crate::compare::parse::emacs_parse_file_org_document;
use crate::compare::parse::get_emacs_version;
use crate::compare::parse::get_org_mode_version;
use crate::compare::sexp::sexp; use crate::compare::sexp::sexp;
use crate::context::GlobalSettings; use crate::context::GlobalSettings;
use crate::context::LocalFileAccessInterface; use crate::context::LocalFileAccessInterface;
use crate::parser::parse_file_with_settings; use crate::parser::parse_file_with_settings;
use crate::parser::parse_with_settings; use crate::parser::parse_with_settings;
use crate::util::print_versions;
pub async fn run_anonymous_compare<P: AsRef<str>>( pub async fn run_anonymous_compare<P: AsRef<str>>(
org_contents: P, org_contents: P,
@ -128,12 +127,3 @@ pub async fn run_compare_on_file_with_settings<'g, 's, P: AsRef<Path>>(
Ok(true) Ok(true)
} }
async fn print_versions() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("Using emacs version: {}", get_emacs_version().await?.trim());
eprintln!(
"Using org-mode version: {}",
get_org_mode_version().await?.trim()
);
Ok(())
}

View File

@ -143,40 +143,3 @@ where
} }
output output
} }
pub async fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(message "%s" (version))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}
pub async fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(org-mode)
(message "%s" (org-version nil t nil))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}

View File

@ -10,6 +10,8 @@ extern crate test;
#[cfg(feature = "compare")] #[cfg(feature = "compare")]
pub mod compare; pub mod compare;
#[cfg(feature = "compare")]
mod util;
mod context; mod context;
mod error; mod error;

47
src/util/mod.rs Normal file
View File

@ -0,0 +1,47 @@
use tokio::process::Command;
pub(crate) async fn print_versions() -> Result<(), Box<dyn std::error::Error>> {
eprintln!("Using emacs version: {}", get_emacs_version().await?.trim());
eprintln!(
"Using org-mode version: {}",
get_org_mode_version().await?.trim()
);
Ok(())
}
pub(crate) async fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(message "%s" (version))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}
pub(crate) async fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn
(org-mode)
(message "%s" (org-version nil t nil))
)"#;
let mut cmd = Command::new("emacs");
let cmd = cmd
.arg("-q")
.arg("--no-site-file")
.arg("--no-splash")
.arg("--batch")
.arg("--eval")
.arg(elisp_script);
let out = cmd.output().await?;
out.status.exit_ok()?;
Ok(String::from_utf8(out.stderr)?)
}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::AngleLink;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmAngleLink<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmAngleLink<'s>,
Document<'s>, AngleLink<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmAngleLink {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

128
src/wasm/ast_node.rs Normal file
View File

@ -0,0 +1,128 @@
use serde::Serialize;
use super::angle_link::WasmAngleLink;
use super::babel_call::WasmBabelCall;
use super::bold::WasmBold;
use super::center_block::WasmCenterBlock;
use super::citation::WasmCitation;
use super::citation_reference::WasmCitationReference;
use super::clock::WasmClock;
use super::code::WasmCode;
use super::comment::WasmComment;
use super::comment_block::WasmCommentBlock;
use super::diary_sexp::WasmDiarySexp;
use super::document::WasmDocument;
use super::drawer::WasmDrawer;
use super::dynamic_block::WasmDynamicBlock;
use super::entity::WasmEntity;
use super::example_block::WasmExampleBlock;
use super::export_block::WasmExportBlock;
use super::export_snippet::WasmExportSnippet;
use super::fixed_width_area::WasmFixedWidthArea;
use super::footnote_definition::WasmFootnoteDefinition;
use super::footnote_reference::WasmFootnoteReference;
use super::headline::WasmHeadline;
use super::horizontal_rule::WasmHorizontalRule;
use super::inline_babel_call::WasmInlineBabelCall;
use super::inline_source_block::WasmInlineSourceBlock;
use super::italic::WasmItalic;
use super::keyword::WasmKeyword;
use super::latex_environment::WasmLatexEnvironment;
use super::latex_fragment::WasmLatexFragment;
use super::line_break::WasmLineBreak;
use super::node_property::WasmNodeProperty;
use super::org_macro::WasmOrgMacro;
use super::paragraph::WasmParagraph;
use super::plain_link::WasmPlainLink;
use super::plain_list::WasmPlainList;
use super::plain_list_item::WasmPlainListItem;
use super::plain_text::WasmPlainText;
use super::planning::WasmPlanning;
use super::property_drawer::WasmPropertyDrawer;
use super::quote_block::WasmQuoteBlock;
use super::radio_link::WasmRadioLink;
use super::radio_target::WasmRadioTarget;
use super::regular_link::WasmRegularLink;
use super::section::WasmSection;
use super::special_block::WasmSpecialBlock;
use super::src_block::WasmSrcBlock;
use super::statistics_cookie::WasmStatisticsCookie;
use super::strike_through::WasmStrikeThrough;
use super::subscript::WasmSubscript;
use super::superscript::WasmSuperscript;
use super::table::WasmTable;
use super::table_cell::WasmTableCell;
use super::table_row::WasmTableRow;
use super::target::WasmTarget;
use super::timestamp::WasmTimestamp;
use super::underline::WasmUnderline;
use super::verbatim::WasmVerbatim;
use super::verse_block::WasmVerseBlock;
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub enum WasmAstNode<'s> {
// Document Nodes
Document(WasmDocument<'s>),
Headline(WasmHeadline<'s>),
Section(WasmSection<'s>),
// Elements
Paragraph(WasmParagraph<'s>),
PlainList(WasmPlainList<'s>),
PlainListItem(WasmPlainListItem<'s>),
CenterBlock(WasmCenterBlock<'s>),
QuoteBlock(WasmQuoteBlock<'s>),
SpecialBlock(WasmSpecialBlock<'s>),
DynamicBlock(WasmDynamicBlock<'s>),
FootnoteDefinition(WasmFootnoteDefinition<'s>),
Comment(WasmComment<'s>),
Drawer(WasmDrawer<'s>),
PropertyDrawer(WasmPropertyDrawer<'s>),
NodeProperty(WasmNodeProperty<'s>),
Table(WasmTable<'s>),
TableRow(WasmTableRow<'s>),
VerseBlock(WasmVerseBlock<'s>),
CommentBlock(WasmCommentBlock<'s>),
ExampleBlock(WasmExampleBlock<'s>),
ExportBlock(WasmExportBlock<'s>),
SrcBlock(WasmSrcBlock<'s>),
Clock(WasmClock<'s>),
DiarySexp(WasmDiarySexp<'s>),
Planning(WasmPlanning<'s>),
FixedWidthArea(WasmFixedWidthArea<'s>),
HorizontalRule(WasmHorizontalRule<'s>),
Keyword(WasmKeyword<'s>),
BabelCall(WasmBabelCall<'s>),
LatexEnvironment(WasmLatexEnvironment<'s>),
// Objects
Bold(WasmBold<'s>),
Italic(WasmItalic<'s>),
Underline(WasmUnderline<'s>),
StrikeThrough(WasmStrikeThrough<'s>),
Code(WasmCode<'s>),
Verbatim(WasmVerbatim<'s>),
PlainText(WasmPlainText<'s>),
RegularLink(WasmRegularLink<'s>),
RadioLink(WasmRadioLink<'s>),
RadioTarget(WasmRadioTarget<'s>),
PlainLink(WasmPlainLink<'s>),
AngleLink(WasmAngleLink<'s>),
OrgMacro(WasmOrgMacro<'s>),
Entity(WasmEntity<'s>),
LatexFragment(WasmLatexFragment<'s>),
ExportSnippet(WasmExportSnippet<'s>),
FootnoteReference(WasmFootnoteReference<'s>),
Citation(WasmCitation<'s>),
CitationReference(WasmCitationReference<'s>),
InlineBabelCall(WasmInlineBabelCall<'s>),
InlineSourceBlock(WasmInlineSourceBlock<'s>),
LineBreak(WasmLineBreak<'s>),
Target(WasmTarget<'s>),
StatisticsCookie(WasmStatisticsCookie<'s>),
Subscript(WasmSubscript<'s>),
Superscript(WasmSuperscript<'s>),
TableCell(WasmTableCell<'s>),
Timestamp(WasmTimestamp<'s>),
}
impl<'s> WasmAstNode<'s> {}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::BabelCall;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmBabelCall<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmBabelCall<'s>,
Document<'s>, BabelCall<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmBabelCall {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Bold;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmBold<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmBold<'s>,
Document<'s>, Bold<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmBold {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::CenterBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmCenterBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmCenterBlock<'s>,
Document<'s>, CenterBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmCenterBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Citation;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmCitation<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmCitation<'s>,
Document<'s>, Citation<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmCitation {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::CitationReference;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmCitationReference<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmCitationReference<'s>,
Document<'s>, CitationReference<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmCitationReference {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Clock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmClock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmClock<'s>,
Document<'s>, Clock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmClock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Code;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmCode<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmCode<'s>,
Document<'s>, Code<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmCode {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Comment;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmComment<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmComment<'s>,
Document<'s>, Comment<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmComment {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::CommentBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmCommentBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmCommentBlock<'s>,
Document<'s>, CommentBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmCommentBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

3
src/wasm/compare/mod.rs Normal file
View File

@ -0,0 +1,3 @@
mod runner;
pub(crate) use runner::wasm_run_anonymous_compare_with_settings;

View File

@ -0,0 +1,44 @@
use organic::parser::parse_with_settings;
use organic::settings::GlobalSettings;
use crate::util::print_versions;
pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
org_contents: P,
global_settings: &GlobalSettings<'g, 's>,
silent: bool,
) -> Result<bool, Box<dyn std::error::Error>> {
// TODO: This is a work-around to pretend that dos line endings do not exist. It would be better to handle the difference in line endings.
let org_contents = org_contents.as_ref().replace("\r\n", "\n");
let org_contents = org_contents.as_str();
if !silent {
print_versions().await?;
}
let rust_parsed = parse_with_settings(org_contents, global_settings)?;
// let org_sexp = emacs_parse_anonymous_org_document(org_contents, global_settings).await?;
// let (_remaining, parsed_sexp) = sexp(org_sexp.as_str()).map_err(|e| e.to_string())?;
if !silent {
println!("{}\n\n\n", org_contents);
// println!("{}", org_sexp);
println!("{:#?}", rust_parsed);
}
// We do the diffing after printing out both parsed forms in case the diffing panics
// let diff_result = compare_document(&parsed_sexp, &rust_parsed)?;
// if !silent {
// diff_result.print(org_contents)?;
// }
// if diff_result.is_bad() {
// return Ok(false);
// } else if !silent {
// println!(
// "{color}Entire document passes.{reset}",
// color = DiffResult::foreground_color(0, 255, 0),
// reset = DiffResult::reset_color(),
// );
// }
Ok(true)
}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::DiarySexp;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmDiarySexp<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmDiarySexp<'s>,
Document<'s>, DiarySexp<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmDiarySexp {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,33 +1,72 @@
use std::marker::PhantomData;
use organic::types::Document; use organic::types::Document;
use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties; use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, additional_properties: Vec<(String, &'s str)>,
phantom: PhantomData<&'s ()>, children: Vec<WasmAstNode<'s>>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmDocument<'s>,
Document<'s>, Document<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
let additional_properties: Vec<(String, &str)> = original
.get_additional_properties()
.map(|node_property| {
(
format!(":{}", node_property.property_name.to_uppercase()),
node_property.value.unwrap_or(""),
)
})
.collect();
let children = original
.zeroth_section
.iter()
.map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_>>::into)
})
.chain(original.children.iter().map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_>>::into)
}))
.collect::<Result<Vec<_>, _>>()?;
// let children = original
// .children
// .iter()
// .map(|child| {
// child
// .to_wasm(wasm_context.clone())
// .map(Into::<WasmAstNode<'_>>::into)
// })
// .collect::<Result<Vec<_>, _>>()?;
Ok(WasmDocument { Ok(WasmDocument {
standard_properties, standard_properties,
children: Vec::new(), additional_properties,
phantom: PhantomData, children,
}) })
} }
); );
impl<'s> Into<WasmAstNode<'s>> for WasmDocument<'s> {
fn into(self) -> WasmAstNode<'s> {
WasmAstNode::Document(self)
}
}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Drawer;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmDrawer<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmDrawer<'s>,
Document<'s>, Drawer<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmDrawer {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::DynamicBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmDynamicBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmDynamicBlock<'s>,
Document<'s>, DynamicBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmDynamicBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Entity;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmEntity<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmEntity<'s>,
Document<'s>, Entity<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmEntity {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::ExampleBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmExampleBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmExampleBlock<'s>,
Document<'s>, ExampleBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmExampleBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::ExportBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmExportBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmExportBlock<'s>,
Document<'s>, ExportBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmExportBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::ExportSnippet;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmExportSnippet<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmExportSnippet<'s>,
Document<'s>, ExportSnippet<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmExportSnippet {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::FixedWidthArea;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmFixedWidthArea<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmFixedWidthArea<'s>,
Document<'s>, FixedWidthArea<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmFixedWidthArea {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::FootnoteDefinition;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmFootnoteDefinition<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmFootnoteDefinition<'s>,
Document<'s>, FootnoteDefinition<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmFootnoteDefinition {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::FootnoteReference;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmFootnoteReference<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmFootnoteReference<'s>,
Document<'s>, FootnoteReference<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmFootnoteReference {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,33 +1,40 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Heading;
use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties; use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "headline")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmHeadline<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmHeadline<'s>,
Document<'s>, Heading<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmHeadline {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,
}) })
} }
); );
impl<'s> Into<WasmAstNode<'s>> for WasmHeadline<'s> {
fn into(self) -> WasmAstNode<'s> {
WasmAstNode::Headline(self)
}
}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::HorizontalRule;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmHorizontalRule<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmHorizontalRule<'s>,
Document<'s>, HorizontalRule<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmHorizontalRule {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::InlineBabelCall;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmInlineBabelCall<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmInlineBabelCall<'s>,
Document<'s>, InlineBabelCall<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmInlineBabelCall {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::InlineSourceBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmInlineSourceBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmInlineSourceBlock<'s>,
Document<'s>, InlineSourceBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmInlineSourceBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Italic;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmItalic<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmItalic<'s>,
Document<'s>, Italic<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmItalic {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Keyword;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmKeyword<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmKeyword<'s>,
Document<'s>, Keyword<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmKeyword {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::LatexEnvironment;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmLatexEnvironment<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmLatexEnvironment<'s>,
Document<'s>, LatexEnvironment<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmLatexEnvironment {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::LatexFragment;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmLatexFragment<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmLatexFragment<'s>,
Document<'s>, LatexFragment<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmLatexFragment {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::LineBreak;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmLineBreak<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmLineBreak<'s>,
Document<'s>, LineBreak<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmLineBreak {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

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

View File

@ -1,4 +1,5 @@
mod angle_link; mod angle_link;
mod ast_node;
mod babel_call; mod babel_call;
mod bold; mod bold;
mod center_block; mod center_block;
@ -8,6 +9,8 @@ mod clock;
mod code; mod code;
mod comment; mod comment;
mod comment_block; mod comment_block;
#[cfg(feature = "wasm_test")]
pub(crate) mod compare;
mod diary_sexp; mod diary_sexp;
mod document; mod document;
mod drawer; mod drawer;
@ -61,6 +64,7 @@ mod underline;
mod verbatim; mod verbatim;
mod verse_block; mod verse_block;
pub(crate) use parse_result::wasm_parse_org;
pub(crate) use parse_result::ParseResult; pub(crate) use parse_result::ParseResult;
pub(crate) use to_wasm::ToWasm; pub(crate) use to_wasm::ToWasm;
pub(crate) use to_wasm::ToWasmContext; pub(crate) use to_wasm::ToWasmContext;

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::NodeProperty;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmNodeProperty<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmNodeProperty<'s>,
Document<'s>, NodeProperty<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmNodeProperty {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::OrgMacro;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmOrgMacro<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmOrgMacro<'s>,
Document<'s>, OrgMacro<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmOrgMacro {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Paragraph;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmParagraph<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmParagraph<'s>,
Document<'s>, Paragraph<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmParagraph {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,9 +1,12 @@
use serde::Deserialize; use organic::parser::parse_with_settings;
use organic::settings::GlobalSettings;
use serde::Serialize; use serde::Serialize;
use super::document::WasmDocument; use super::document::WasmDocument;
use super::ToWasm;
use super::ToWasmContext;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "status", content = "content")] #[serde(tag = "status", content = "content")]
pub(crate) enum ParseResult<'s> { pub(crate) enum ParseResult<'s> {
#[serde(rename = "success")] #[serde(rename = "success")]
@ -12,3 +15,18 @@ pub(crate) enum ParseResult<'s> {
#[serde(rename = "error")] #[serde(rename = "error")]
Error(String), Error(String),
} }
pub(crate) 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

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::PlainLink;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmPlainLink<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmPlainLink<'s>,
Document<'s>, PlainLink<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmPlainLink {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::PlainList;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmPlainList<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmPlainList<'s>,
Document<'s>, PlainList<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmPlainList {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::PlainListItem;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmPlainListItem<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmPlainListItem<'s>,
Document<'s>, PlainListItem<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmPlainListItem {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::PlainText;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmPlainText<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmPlainText<'s>,
Document<'s>, PlainText<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmPlainText {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Planning;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmPlanning<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmPlanning<'s>,
Document<'s>, Planning<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmPlanning {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::PropertyDrawer;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmPropertyDrawer<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmPropertyDrawer<'s>,
Document<'s>, PropertyDrawer<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmPropertyDrawer {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::QuoteBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmQuoteBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmQuoteBlock<'s>,
Document<'s>, QuoteBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmQuoteBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::RadioLink;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmRadioLink<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmRadioLink<'s>,
Document<'s>, RadioLink<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmRadioLink {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::RadioTarget;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmRadioTarget<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmRadioTarget<'s>,
Document<'s>, RadioTarget<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmRadioTarget {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::RegularLink;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmRegularLink<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmRegularLink<'s>,
Document<'s>, RegularLink<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmRegularLink {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,33 +1,40 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Section;
use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties; use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "section")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmSection<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmSection<'s>,
Document<'s>, Section<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmSection {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,
}) })
} }
); );
impl<'s> Into<WasmAstNode<'s>> for WasmSection<'s> {
fn into(self) -> WasmAstNode<'s> {
WasmAstNode::Section(self)
}
}

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::SpecialBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmSpecialBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmSpecialBlock<'s>,
Document<'s>, SpecialBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmSpecialBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::SrcBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmSrcBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmSrcBlock<'s>,
Document<'s>, SrcBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmSrcBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -6,7 +6,7 @@ use serde::Serialize;
use super::to_wasm::ToWasmContext; use super::to_wasm::ToWasmContext;
use super::to_wasm::ToWasmStandardProperties; use super::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
pub(crate) struct WasmStandardProperties { pub(crate) struct WasmStandardProperties {
begin: usize, begin: usize,
end: usize, end: usize,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::StatisticsCookie;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmStatisticsCookie<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmStatisticsCookie<'s>,
Document<'s>, StatisticsCookie<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmStatisticsCookie {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::StrikeThrough;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmStrikeThrough<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmStrikeThrough<'s>,
Document<'s>, StrikeThrough<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmStrikeThrough {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Subscript;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmSubscript<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmSubscript<'s>,
Document<'s>, Subscript<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmSubscript {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Superscript;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmSuperscript<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmSuperscript<'s>,
Document<'s>, Superscript<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmSuperscript {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Table;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmTable<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmTable<'s>,
Document<'s>, Table<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmTable {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::TableCell;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmTableCell<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmTableCell<'s>,
Document<'s>, TableCell<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmTableCell {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::TableRow;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmTableRow<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmTableRow<'s>,
Document<'s>, TableRow<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmTableRow {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Target;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmTarget<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmTarget<'s>,
Document<'s>, Target<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmTarget {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Timestamp;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmTimestamp<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmTimestamp<'s>,
Document<'s>, Timestamp<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmTimestamp {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Underline;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmUnderline<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmUnderline<'s>,
Document<'s>, Underline<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmUnderline {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::Verbatim;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmVerbatim<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmVerbatim<'s>,
Document<'s>, Verbatim<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmVerbatim {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,

View File

@ -1,6 +1,6 @@
use std::marker::PhantomData; use std::marker::PhantomData;
use organic::types::Document; use organic::types::VerseBlock;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
@ -9,22 +9,23 @@ use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> { pub(crate) struct WasmVerseBlock<'s> {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<()>, children: Vec<()>,
phantom: PhantomData<&'s ()>, phantom: PhantomData<&'s ()>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s>, WasmVerseBlock<'s>,
Document<'s>, VerseBlock<'s>,
original,
wasm_context, wasm_context,
standard_properties, standard_properties,
{ {
Ok(WasmDocument { Ok(WasmVerseBlock {
standard_properties, standard_properties,
children: Vec::new(), children: Vec::new(),
phantom: PhantomData, phantom: PhantomData,