Compare commits
18 Commits
v0.1.13
...
e622d9fa6b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e622d9fa6b | ||
|
|
8186fbb8b3 | ||
|
|
68ccff74fa | ||
|
|
9a13cb72c6 | ||
|
|
65abaa332f | ||
|
|
67e5829fd9 | ||
|
|
995b41e697 | ||
|
|
eb51bdfe2f | ||
|
|
bbb9ec637a | ||
|
|
dc012b49f5 | ||
|
|
13863a68f7 | ||
|
|
2962f76c81 | ||
|
|
b9b3ef6e74 | ||
|
|
310ab2eab2 | ||
|
|
53320070da | ||
|
|
2d5593681f | ||
|
|
b3f97dbb40 | ||
|
|
a48d76321e |
21
Cargo.toml
21
Cargo.toml
@@ -39,17 +39,31 @@ path = "src/lib.rs"
|
|||||||
path = "src/bin_foreign_document_test.rs"
|
path = "src/bin_foreign_document_test.rs"
|
||||||
required-features = ["foreign_document_test"]
|
required-features = ["foreign_document_test"]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wasm"
|
||||||
|
path = "src/bin_wasm.rs"
|
||||||
|
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"
|
||||||
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
||||||
opentelemetry-otlp = { version = "0.13.0", optional = true }
|
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-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 }
|
||||||
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
|
||||||
walkdir = { version = "2.3.3", optional = true }
|
walkdir = { version = "2.3.3", optional = true }
|
||||||
|
wasm-bindgen = { version = "0.2.89", optional = true }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
walkdir = "2.3.3"
|
walkdir = "2.3.3"
|
||||||
@@ -60,6 +74,8 @@ compare = ["tokio/process", "tokio/macros"]
|
|||||||
foreign_document_test = ["compare", "dep:futures", "tokio/sync", "dep:walkdir", "tokio/process"]
|
foreign_document_test = ["compare", "dep:futures", "tokio/sync", "dep:walkdir", "tokio/process"]
|
||||||
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_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]
|
||||||
@@ -79,3 +95,8 @@ strip = "symbols"
|
|||||||
inherits = "release"
|
inherits = "release"
|
||||||
lto = true
|
lto = true
|
||||||
debug = true
|
debug = true
|
||||||
|
|
||||||
|
[profile.wasm]
|
||||||
|
inherits = "release"
|
||||||
|
lto = true
|
||||||
|
strip = true
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -29,6 +29,15 @@ build:
|
|||||||
release:
|
release:
|
||||||
> cargo build --release $(RELEASEFLAGS)
|
> cargo build --release $(RELEASEFLAGS)
|
||||||
|
|
||||||
|
.PHONY: wasm
|
||||||
|
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
|
||||||
|
|
||||||
|
.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
|
||||||
|
|||||||
@@ -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")]
|
||||||
|
|||||||
13
src/bin_wasm.rs
Normal file
13
src/bin_wasm.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use wasm::wasm_parse_org;
|
||||||
|
use wasm_bindgen::prelude::wasm_bindgen;
|
||||||
|
|
||||||
|
mod error;
|
||||||
|
mod wasm;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
||||||
|
let rust_parsed = wasm_parse_org(org_contents);
|
||||||
|
serde_wasm_bindgen::to_value(&rust_parsed).unwrap()
|
||||||
|
}
|
||||||
72
src/bin_wasm_test.rs
Normal file
72
src/bin_wasm_test.rs
Normal 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)
|
||||||
|
}
|
||||||
@@ -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(())
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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)?)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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
47
src/util/mod.rs
Normal 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)?)
|
||||||
|
}
|
||||||
34
src/wasm/angle_link.rs
Normal file
34
src/wasm/angle_link.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::AngleLink;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmAngleLink<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmAngleLink<'s>,
|
||||||
|
AngleLink<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmAngleLink {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
128
src/wasm/ast_node.rs
Normal file
128
src/wasm/ast_node.rs
Normal 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> {}
|
||||||
34
src/wasm/babel_call.rs
Normal file
34
src/wasm/babel_call.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::BabelCall;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmBabelCall<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmBabelCall<'s>,
|
||||||
|
BabelCall<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmBabelCall {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/bold.rs
Normal file
34
src/wasm/bold.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Bold;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmBold<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmBold<'s>,
|
||||||
|
Bold<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmBold {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/center_block.rs
Normal file
34
src/wasm/center_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::CenterBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmCenterBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmCenterBlock<'s>,
|
||||||
|
CenterBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmCenterBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/citation.rs
Normal file
34
src/wasm/citation.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Citation;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmCitation<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmCitation<'s>,
|
||||||
|
Citation<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmCitation {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/citation_reference.rs
Normal file
34
src/wasm/citation_reference.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::CitationReference;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmCitationReference<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmCitationReference<'s>,
|
||||||
|
CitationReference<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmCitationReference {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/clock.rs
Normal file
34
src/wasm/clock.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Clock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmClock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmClock<'s>,
|
||||||
|
Clock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmClock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/code.rs
Normal file
34
src/wasm/code.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Code;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmCode<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmCode<'s>,
|
||||||
|
Code<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmCode {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/comment.rs
Normal file
34
src/wasm/comment.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Comment;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmComment<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmComment<'s>,
|
||||||
|
Comment<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmComment {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/comment_block.rs
Normal file
34
src/wasm/comment_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::CommentBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmCommentBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmCommentBlock<'s>,
|
||||||
|
CommentBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmCommentBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
3
src/wasm/compare/mod.rs
Normal file
3
src/wasm/compare/mod.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
mod runner;
|
||||||
|
|
||||||
|
pub(crate) use runner::wasm_run_anonymous_compare_with_settings;
|
||||||
44
src/wasm/compare/runner.rs
Normal file
44
src/wasm/compare/runner.rs
Normal 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)
|
||||||
|
}
|
||||||
34
src/wasm/diary_sexp.rs
Normal file
34
src/wasm/diary_sexp.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::DiarySexp;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmDiarySexp<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmDiarySexp<'s>,
|
||||||
|
DiarySexp<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmDiarySexp {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
72
src/wasm/document.rs
Normal file
72
src/wasm/document.rs
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
use organic::types::Document;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmDocument<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
additional_properties: Vec<(String, &'s str)>,
|
||||||
|
children: Vec<WasmAstNode<'s>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmDocument<'s>,
|
||||||
|
Document<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
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 {
|
||||||
|
standard_properties,
|
||||||
|
additional_properties,
|
||||||
|
children,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
impl<'s> Into<WasmAstNode<'s>> for WasmDocument<'s> {
|
||||||
|
fn into(self) -> WasmAstNode<'s> {
|
||||||
|
WasmAstNode::Document(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/wasm/drawer.rs
Normal file
34
src/wasm/drawer.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Drawer;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmDrawer<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmDrawer<'s>,
|
||||||
|
Drawer<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmDrawer {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/dynamic_block.rs
Normal file
34
src/wasm/dynamic_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::DynamicBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmDynamicBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmDynamicBlock<'s>,
|
||||||
|
DynamicBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmDynamicBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/entity.rs
Normal file
34
src/wasm/entity.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Entity;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmEntity<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmEntity<'s>,
|
||||||
|
Entity<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmEntity {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/example_block.rs
Normal file
34
src/wasm/example_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::ExampleBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmExampleBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmExampleBlock<'s>,
|
||||||
|
ExampleBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmExampleBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/export_block.rs
Normal file
34
src/wasm/export_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::ExportBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmExportBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmExportBlock<'s>,
|
||||||
|
ExportBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmExportBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/export_snippet.rs
Normal file
34
src/wasm/export_snippet.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::ExportSnippet;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmExportSnippet<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmExportSnippet<'s>,
|
||||||
|
ExportSnippet<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmExportSnippet {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/fixed_width_area.rs
Normal file
34
src/wasm/fixed_width_area.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::FixedWidthArea;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmFixedWidthArea<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmFixedWidthArea<'s>,
|
||||||
|
FixedWidthArea<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmFixedWidthArea {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/footnote_definition.rs
Normal file
34
src/wasm/footnote_definition.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::FootnoteDefinition;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmFootnoteDefinition<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmFootnoteDefinition<'s>,
|
||||||
|
FootnoteDefinition<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmFootnoteDefinition {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/footnote_reference.rs
Normal file
34
src/wasm/footnote_reference.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::FootnoteReference;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmFootnoteReference<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmFootnoteReference<'s>,
|
||||||
|
FootnoteReference<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmFootnoteReference {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
40
src/wasm/headline.rs
Normal file
40
src/wasm/headline.rs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Heading;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "headline")]
|
||||||
|
pub(crate) struct WasmHeadline<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmHeadline<'s>,
|
||||||
|
Heading<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmHeadline {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
impl<'s> Into<WasmAstNode<'s>> for WasmHeadline<'s> {
|
||||||
|
fn into(self) -> WasmAstNode<'s> {
|
||||||
|
WasmAstNode::Headline(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/wasm/horizontal_rule.rs
Normal file
34
src/wasm/horizontal_rule.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::HorizontalRule;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmHorizontalRule<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmHorizontalRule<'s>,
|
||||||
|
HorizontalRule<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmHorizontalRule {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/inline_babel_call.rs
Normal file
34
src/wasm/inline_babel_call.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::InlineBabelCall;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmInlineBabelCall<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmInlineBabelCall<'s>,
|
||||||
|
InlineBabelCall<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmInlineBabelCall {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/inline_source_block.rs
Normal file
34
src/wasm/inline_source_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::InlineSourceBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmInlineSourceBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmInlineSourceBlock<'s>,
|
||||||
|
InlineSourceBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmInlineSourceBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/italic.rs
Normal file
34
src/wasm/italic.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Italic;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmItalic<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmItalic<'s>,
|
||||||
|
Italic<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmItalic {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/keyword.rs
Normal file
34
src/wasm/keyword.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Keyword;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmKeyword<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmKeyword<'s>,
|
||||||
|
Keyword<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmKeyword {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/latex_environment.rs
Normal file
34
src/wasm/latex_environment.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::LatexEnvironment;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmLatexEnvironment<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmLatexEnvironment<'s>,
|
||||||
|
LatexEnvironment<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmLatexEnvironment {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/latex_fragment.rs
Normal file
34
src/wasm/latex_fragment.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::LatexFragment;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmLatexFragment<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmLatexFragment<'s>,
|
||||||
|
LatexFragment<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmLatexFragment {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/line_break.rs
Normal file
34
src/wasm/line_break.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::LineBreak;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmLineBreak<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmLineBreak<'s>,
|
||||||
|
LineBreak<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmLineBreak {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
22
src/wasm/macros.rs
Normal file
22
src/wasm/macros.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/// Write the implementation for the intermediate ast node.
|
||||||
|
///
|
||||||
|
/// This exists to make changing the type signature easier.
|
||||||
|
macro_rules! to_wasm {
|
||||||
|
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => {
|
||||||
|
impl<'s> ToWasm for $istruct {
|
||||||
|
type Output = $ostruct;
|
||||||
|
|
||||||
|
fn to_wasm(
|
||||||
|
&self,
|
||||||
|
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
|
||||||
|
) -> Result<Self::Output, crate::error::CustomError> {
|
||||||
|
let $original = self;
|
||||||
|
let $standard_properties =
|
||||||
|
self.to_wasm_standard_properties($wasm_context.clone())?;
|
||||||
|
$fnbody
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use to_wasm;
|
||||||
70
src/wasm/mod.rs
Normal file
70
src/wasm/mod.rs
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
mod angle_link;
|
||||||
|
mod ast_node;
|
||||||
|
mod babel_call;
|
||||||
|
mod bold;
|
||||||
|
mod center_block;
|
||||||
|
mod citation;
|
||||||
|
mod citation_reference;
|
||||||
|
mod clock;
|
||||||
|
mod code;
|
||||||
|
mod comment;
|
||||||
|
mod comment_block;
|
||||||
|
#[cfg(feature = "wasm_test")]
|
||||||
|
pub(crate) mod compare;
|
||||||
|
mod diary_sexp;
|
||||||
|
mod document;
|
||||||
|
mod drawer;
|
||||||
|
mod dynamic_block;
|
||||||
|
mod entity;
|
||||||
|
mod example_block;
|
||||||
|
mod export_block;
|
||||||
|
mod export_snippet;
|
||||||
|
mod fixed_width_area;
|
||||||
|
mod footnote_definition;
|
||||||
|
mod footnote_reference;
|
||||||
|
mod headline;
|
||||||
|
mod horizontal_rule;
|
||||||
|
mod inline_babel_call;
|
||||||
|
mod inline_source_block;
|
||||||
|
mod italic;
|
||||||
|
mod keyword;
|
||||||
|
mod latex_environment;
|
||||||
|
mod latex_fragment;
|
||||||
|
mod line_break;
|
||||||
|
mod macros;
|
||||||
|
mod node_property;
|
||||||
|
mod org_macro;
|
||||||
|
mod paragraph;
|
||||||
|
mod parse_result;
|
||||||
|
mod plain_link;
|
||||||
|
mod plain_list;
|
||||||
|
mod plain_list_item;
|
||||||
|
mod plain_text;
|
||||||
|
mod planning;
|
||||||
|
mod property_drawer;
|
||||||
|
mod quote_block;
|
||||||
|
mod radio_link;
|
||||||
|
mod radio_target;
|
||||||
|
mod regular_link;
|
||||||
|
mod section;
|
||||||
|
mod special_block;
|
||||||
|
mod src_block;
|
||||||
|
mod standard_properties;
|
||||||
|
mod statistics_cookie;
|
||||||
|
mod strike_through;
|
||||||
|
mod subscript;
|
||||||
|
mod superscript;
|
||||||
|
mod table;
|
||||||
|
mod table_cell;
|
||||||
|
mod table_row;
|
||||||
|
mod target;
|
||||||
|
mod timestamp;
|
||||||
|
mod to_wasm;
|
||||||
|
mod underline;
|
||||||
|
mod verbatim;
|
||||||
|
mod verse_block;
|
||||||
|
|
||||||
|
pub(crate) use parse_result::wasm_parse_org;
|
||||||
|
pub(crate) use parse_result::ParseResult;
|
||||||
|
pub(crate) use to_wasm::ToWasm;
|
||||||
|
pub(crate) use to_wasm::ToWasmContext;
|
||||||
34
src/wasm/node_property.rs
Normal file
34
src/wasm/node_property.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::NodeProperty;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmNodeProperty<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmNodeProperty<'s>,
|
||||||
|
NodeProperty<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmNodeProperty {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/org_macro.rs
Normal file
34
src/wasm/org_macro.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::OrgMacro;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmOrgMacro<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmOrgMacro<'s>,
|
||||||
|
OrgMacro<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmOrgMacro {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/paragraph.rs
Normal file
34
src/wasm/paragraph.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Paragraph;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmParagraph<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmParagraph<'s>,
|
||||||
|
Paragraph<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmParagraph {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
32
src/wasm/parse_result.rs
Normal file
32
src/wasm/parse_result.rs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
use organic::parser::parse_with_settings;
|
||||||
|
use organic::settings::GlobalSettings;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::document::WasmDocument;
|
||||||
|
use super::ToWasm;
|
||||||
|
use super::ToWasmContext;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "status", content = "content")]
|
||||||
|
pub(crate) enum ParseResult<'s> {
|
||||||
|
#[serde(rename = "success")]
|
||||||
|
Success(WasmDocument<'s>),
|
||||||
|
|
||||||
|
#[serde(rename = "error")]
|
||||||
|
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
|
||||||
|
}
|
||||||
34
src/wasm/plain_link.rs
Normal file
34
src/wasm/plain_link.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::PlainLink;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmPlainLink<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmPlainLink<'s>,
|
||||||
|
PlainLink<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmPlainLink {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/plain_list.rs
Normal file
34
src/wasm/plain_list.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::PlainList;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmPlainList<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmPlainList<'s>,
|
||||||
|
PlainList<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmPlainList {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/plain_list_item.rs
Normal file
34
src/wasm/plain_list_item.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::PlainListItem;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmPlainListItem<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmPlainListItem<'s>,
|
||||||
|
PlainListItem<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmPlainListItem {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/plain_text.rs
Normal file
34
src/wasm/plain_text.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::PlainText;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmPlainText<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmPlainText<'s>,
|
||||||
|
PlainText<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmPlainText {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/planning.rs
Normal file
34
src/wasm/planning.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Planning;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmPlanning<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmPlanning<'s>,
|
||||||
|
Planning<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmPlanning {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/property_drawer.rs
Normal file
34
src/wasm/property_drawer.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::PropertyDrawer;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmPropertyDrawer<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmPropertyDrawer<'s>,
|
||||||
|
PropertyDrawer<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmPropertyDrawer {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/quote_block.rs
Normal file
34
src/wasm/quote_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::QuoteBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmQuoteBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmQuoteBlock<'s>,
|
||||||
|
QuoteBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmQuoteBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/radio_link.rs
Normal file
34
src/wasm/radio_link.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::RadioLink;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmRadioLink<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmRadioLink<'s>,
|
||||||
|
RadioLink<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmRadioLink {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/radio_target.rs
Normal file
34
src/wasm/radio_target.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::RadioTarget;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmRadioTarget<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmRadioTarget<'s>,
|
||||||
|
RadioTarget<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmRadioTarget {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/regular_link.rs
Normal file
34
src/wasm/regular_link.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::RegularLink;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmRegularLink<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmRegularLink<'s>,
|
||||||
|
RegularLink<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmRegularLink {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
40
src/wasm/section.rs
Normal file
40
src/wasm/section.rs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Section;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::ast_node::WasmAstNode;
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "section")]
|
||||||
|
pub(crate) struct WasmSection<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmSection<'s>,
|
||||||
|
Section<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmSection {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
impl<'s> Into<WasmAstNode<'s>> for WasmSection<'s> {
|
||||||
|
fn into(self) -> WasmAstNode<'s> {
|
||||||
|
WasmAstNode::Section(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/wasm/special_block.rs
Normal file
34
src/wasm/special_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::SpecialBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmSpecialBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmSpecialBlock<'s>,
|
||||||
|
SpecialBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmSpecialBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/src_block.rs
Normal file
34
src/wasm/src_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::SrcBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmSrcBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmSrcBlock<'s>,
|
||||||
|
SrcBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmSrcBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
71
src/wasm/standard_properties.rs
Normal file
71
src/wasm/standard_properties.rs
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
use organic::types::PostBlank;
|
||||||
|
use organic::types::StandardProperties;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::to_wasm::ToWasmContext;
|
||||||
|
use super::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
pub(crate) struct WasmStandardProperties {
|
||||||
|
begin: usize,
|
||||||
|
end: usize,
|
||||||
|
contents_begin: Option<usize>,
|
||||||
|
contents_end: Option<usize>,
|
||||||
|
post_blank: PostBlank,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'s, SP: StandardProperties<'s>> ToWasmStandardProperties for SP {
|
||||||
|
type Output = WasmStandardProperties;
|
||||||
|
|
||||||
|
fn to_wasm_standard_properties(
|
||||||
|
&self,
|
||||||
|
wasm_context: ToWasmContext<'_>,
|
||||||
|
) -> Result<Self::Output, crate::error::CustomError> {
|
||||||
|
let (begin, end) = get_char_indices(wasm_context.full_document, self.get_source());
|
||||||
|
let (contents_begin, contents_end) = match self.get_contents() {
|
||||||
|
Some(contents) => {
|
||||||
|
let (begin, end) = get_char_indices(wasm_context.full_document, contents);
|
||||||
|
(Some(begin), Some(end))
|
||||||
|
}
|
||||||
|
None => (None, None),
|
||||||
|
};
|
||||||
|
|
||||||
|
let post_blank = self.get_post_blank();
|
||||||
|
Ok(WasmStandardProperties {
|
||||||
|
begin,
|
||||||
|
end,
|
||||||
|
contents_begin,
|
||||||
|
contents_end,
|
||||||
|
post_blank,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_char_indices(original_document: &str, subset: &str) -> (usize, usize) {
|
||||||
|
let (begin_byte, end_byte) = get_rust_byte_offsets(original_document, subset);
|
||||||
|
// Add 1 to make this 1-based to match emacs.
|
||||||
|
let begin_char = original_document[..begin_byte].chars().count() + 1;
|
||||||
|
// Also 1-based:
|
||||||
|
let end_char = begin_char + original_document[begin_byte..end_byte].chars().count();
|
||||||
|
(begin_char, end_char)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Get the byte offset into source that the string slice exists at.
|
||||||
|
///
|
||||||
|
/// These offsets are zero-based.
|
||||||
|
fn get_rust_byte_offsets(original_document: &str, subset: &str) -> (usize, usize) {
|
||||||
|
debug_assert!(is_slice_of(original_document, subset));
|
||||||
|
let offset = subset.as_ptr() as usize - original_document.as_ptr() as usize;
|
||||||
|
let end = offset + subset.len();
|
||||||
|
(offset, end)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check if the child string slice is a slice of the parent string slice.
|
||||||
|
fn is_slice_of(parent: &str, child: &str) -> bool {
|
||||||
|
let parent_start = parent.as_ptr() as usize;
|
||||||
|
let parent_end = parent_start + parent.len();
|
||||||
|
let child_start = child.as_ptr() as usize;
|
||||||
|
let child_end = child_start + child.len();
|
||||||
|
child_start >= parent_start && child_end <= parent_end
|
||||||
|
}
|
||||||
34
src/wasm/statistics_cookie.rs
Normal file
34
src/wasm/statistics_cookie.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::StatisticsCookie;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmStatisticsCookie<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmStatisticsCookie<'s>,
|
||||||
|
StatisticsCookie<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmStatisticsCookie {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/strike_through.rs
Normal file
34
src/wasm/strike_through.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::StrikeThrough;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmStrikeThrough<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmStrikeThrough<'s>,
|
||||||
|
StrikeThrough<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmStrikeThrough {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/subscript.rs
Normal file
34
src/wasm/subscript.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Subscript;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmSubscript<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmSubscript<'s>,
|
||||||
|
Subscript<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmSubscript {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/superscript.rs
Normal file
34
src/wasm/superscript.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Superscript;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmSuperscript<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmSuperscript<'s>,
|
||||||
|
Superscript<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmSuperscript {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/table.rs
Normal file
34
src/wasm/table.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Table;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmTable<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmTable<'s>,
|
||||||
|
Table<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmTable {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/table_cell.rs
Normal file
34
src/wasm/table_cell.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::TableCell;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmTableCell<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmTableCell<'s>,
|
||||||
|
TableCell<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmTableCell {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/table_row.rs
Normal file
34
src/wasm/table_row.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::TableRow;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmTableRow<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmTableRow<'s>,
|
||||||
|
TableRow<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmTableRow {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/target.rs
Normal file
34
src/wasm/target.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Target;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmTarget<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmTarget<'s>,
|
||||||
|
Target<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmTarget {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/timestamp.rs
Normal file
34
src/wasm/timestamp.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Timestamp;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmTimestamp<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmTimestamp<'s>,
|
||||||
|
Timestamp<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmTimestamp {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
27
src/wasm/to_wasm.rs
Normal file
27
src/wasm/to_wasm.rs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
use crate::error::CustomError;
|
||||||
|
|
||||||
|
pub(crate) trait ToWasm {
|
||||||
|
type Output;
|
||||||
|
|
||||||
|
fn to_wasm(&self, full_document: ToWasmContext<'_>) -> Result<Self::Output, CustomError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) trait ToWasmStandardProperties {
|
||||||
|
type Output;
|
||||||
|
|
||||||
|
fn to_wasm_standard_properties(
|
||||||
|
&self,
|
||||||
|
wasm_context: ToWasmContext<'_>,
|
||||||
|
) -> Result<Self::Output, CustomError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub(crate) struct ToWasmContext<'s> {
|
||||||
|
pub(crate) full_document: &'s str,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'s> ToWasmContext<'s> {
|
||||||
|
pub(crate) fn new(full_document: &'s str) -> ToWasmContext<'s> {
|
||||||
|
ToWasmContext { full_document }
|
||||||
|
}
|
||||||
|
}
|
||||||
34
src/wasm/underline.rs
Normal file
34
src/wasm/underline.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Underline;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmUnderline<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmUnderline<'s>,
|
||||||
|
Underline<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmUnderline {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/verbatim.rs
Normal file
34
src/wasm/verbatim.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::Verbatim;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmVerbatim<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmVerbatim<'s>,
|
||||||
|
Verbatim<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmVerbatim {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
34
src/wasm/verse_block.rs
Normal file
34
src/wasm/verse_block.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use organic::types::VerseBlock;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use super::macros::to_wasm;
|
||||||
|
use super::standard_properties::WasmStandardProperties;
|
||||||
|
use super::to_wasm::ToWasm;
|
||||||
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
#[serde(tag = "ast_node")]
|
||||||
|
#[serde(rename = "org-data")]
|
||||||
|
pub(crate) struct WasmVerseBlock<'s> {
|
||||||
|
standard_properties: WasmStandardProperties,
|
||||||
|
children: Vec<()>,
|
||||||
|
phantom: PhantomData<&'s ()>,
|
||||||
|
}
|
||||||
|
|
||||||
|
to_wasm!(
|
||||||
|
WasmVerseBlock<'s>,
|
||||||
|
VerseBlock<'s>,
|
||||||
|
original,
|
||||||
|
wasm_context,
|
||||||
|
standard_properties,
|
||||||
|
{
|
||||||
|
Ok(WasmVerseBlock {
|
||||||
|
standard_properties,
|
||||||
|
children: Vec::new(),
|
||||||
|
phantom: PhantomData,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user