Compare commits
27 Commits
v0.1.13
...
23f4ba4205
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23f4ba4205 | ||
|
|
55ad136283 | ||
|
|
c717541099 | ||
|
|
c2e921c2dc | ||
|
|
e499169f0e | ||
|
|
84c088df67 | ||
|
|
f210f95f99 | ||
|
|
17b81c7c72 | ||
|
|
2911fce7cc | ||
|
|
e622d9fa6b | ||
|
|
8186fbb8b3 | ||
|
|
68ccff74fa | ||
|
|
9a13cb72c6 | ||
|
|
65abaa332f | ||
|
|
67e5829fd9 | ||
|
|
995b41e697 | ||
|
|
eb51bdfe2f | ||
|
|
bbb9ec637a | ||
|
|
dc012b49f5 | ||
|
|
13863a68f7 | ||
|
|
2962f76c81 | ||
|
|
b9b3ef6e74 | ||
|
|
310ab2eab2 | ||
|
|
53320070da | ||
|
|
2d5593681f | ||
|
|
b3f97dbb40 | ||
|
|
a48d76321e |
@@ -192,6 +192,54 @@ spec:
|
||||
]
|
||||
- name: docker-image
|
||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||
- name: run-image-wasm
|
||||
taskRef:
|
||||
name: run-docker-image
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: git-source
|
||||
- name: cargo-cache
|
||||
workspace: cargo-cache
|
||||
runAfter:
|
||||
- run-image-all
|
||||
params:
|
||||
- name: args
|
||||
value:
|
||||
[
|
||||
"--target",
|
||||
"wasm32-unknown-unknown",
|
||||
"--profile",
|
||||
"wasm",
|
||||
"--bin",
|
||||
"wasm",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"wasm",
|
||||
]
|
||||
- name: docker-image
|
||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||
- name: run-image-wasm-test
|
||||
taskRef:
|
||||
name: run-docker-image
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: git-source
|
||||
- name: cargo-cache
|
||||
workspace: cargo-cache
|
||||
runAfter:
|
||||
- run-image-wasm
|
||||
params:
|
||||
- name: args
|
||||
value:
|
||||
[
|
||||
"--bin",
|
||||
"wasm_test",
|
||||
"--no-default-features",
|
||||
"--features",
|
||||
"wasm_test",
|
||||
]
|
||||
- name: docker-image
|
||||
value: "$(params.image-name):$(tasks.fetch-repository.results.commit)"
|
||||
finally:
|
||||
- name: report-success
|
||||
when:
|
||||
|
||||
21
Cargo.toml
21
Cargo.toml
@@ -39,17 +39,31 @@ path = "src/lib.rs"
|
||||
path = "src/bin_foreign_document_test.rs"
|
||||
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]
|
||||
futures = { version = "0.3.28", optional = true }
|
||||
nom = "7.1.1"
|
||||
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
|
||||
opentelemetry-otlp = { version = "0.13.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"] }
|
||||
tracing = { version = "0.1.37", optional = true }
|
||||
tracing-opentelemetry = { version = "0.20.0", optional = true }
|
||||
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
|
||||
walkdir = { version = "2.3.3", optional = true }
|
||||
wasm-bindgen = { version = "0.2.89", optional = true }
|
||||
|
||||
[build-dependencies]
|
||||
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"]
|
||||
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
|
||||
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.
|
||||
[profile.release-lto]
|
||||
@@ -79,3 +95,8 @@ strip = "symbols"
|
||||
inherits = "release"
|
||||
lto = true
|
||||
debug = true
|
||||
|
||||
[profile.wasm]
|
||||
inherits = "release"
|
||||
lto = true
|
||||
strip = true
|
||||
|
||||
9
Makefile
9
Makefile
@@ -29,6 +29,15 @@ build:
|
||||
release:
|
||||
> 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
|
||||
clean:
|
||||
> cargo clean
|
||||
|
||||
@@ -2,5 +2,6 @@ FROM rustlang/rust:nightly-alpine3.17
|
||||
|
||||
RUN apk add --no-cache musl-dev
|
||||
RUN cargo install --locked --no-default-features --features ci-autoclean cargo-cache
|
||||
RUN rustup target add wasm32-unknown-unknown
|
||||
|
||||
ENTRYPOINT ["cargo", "build"]
|
||||
|
||||
76
scripts/build_all_feature_flag_combinations.bash
Executable file
76
scripts/build_all_feature_flag_combinations.bash
Executable file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Time running a single parse without invoking a compare with emacs.
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
: ${PROFILE:="debug"}
|
||||
|
||||
############## Setup #########################
|
||||
|
||||
function cleanup {
|
||||
for f in "${folders[@]}"; do
|
||||
log "Deleting $f"
|
||||
rm -rf "$f"
|
||||
done
|
||||
}
|
||||
folders=()
|
||||
for sig in EXIT INT QUIT HUP TERM; do
|
||||
trap "set +e; cleanup" "$sig"
|
||||
done
|
||||
|
||||
function die {
|
||||
local status_code="$1"
|
||||
shift
|
||||
(>&2 echo "${@}")
|
||||
exit "$status_code"
|
||||
}
|
||||
|
||||
function log {
|
||||
(>&2 echo "${@}")
|
||||
}
|
||||
|
||||
############## Program #########################
|
||||
|
||||
function main {
|
||||
if [ "$#" -gt 0 ]; then
|
||||
export CARGO_TARGET_DIR="$1"
|
||||
else
|
||||
local work_directory=$(mktemp -d -t 'organic.XXXXXX')
|
||||
folders+=("$work_directory")
|
||||
export CARGO_TARGET_DIR="$work_directory"
|
||||
fi
|
||||
local features=(compare foreign_document_test tracing event_count wasm wasm_test)
|
||||
ENABLED_FEATURES= for_each_combination "${features[@]}"
|
||||
}
|
||||
|
||||
function for_each_combination {
|
||||
local additional_flags=()
|
||||
if [ "$PROFILE" = "dev" ] || [ "$PROFILE" = "debug" ]; then
|
||||
PROFILE="debug"
|
||||
else
|
||||
additional_flags+=(--profile "$PROFILE")
|
||||
fi
|
||||
|
||||
|
||||
local flag=$1
|
||||
shift
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
ENABLED_FEATURES="$ENABLED_FEATURES" for_each_combination "${@}"
|
||||
elif [ -z "$ENABLED_FEATURES" ]; then
|
||||
(cd "$DIR/../" && printf "\n\n\n========== no features ==========\n\n\n" && set -x && cargo build "${additional_flags[@]}" --no-default-features)
|
||||
else
|
||||
(cd "$DIR/../" && printf "\n\n\n========== %s ==========\n\n\n" "${ENABLED_FEATURES:1}" && set -x && cargo build "${additional_flags[@]}" --no-default-features --features "${ENABLED_FEATURES:1}")
|
||||
fi
|
||||
|
||||
ENABLED_FEATURES="$ENABLED_FEATURES,$flag"
|
||||
if [ "$#" -gt 0 ]; then
|
||||
ENABLED_FEATURES="$ENABLED_FEATURES" for_each_combination "${@}"
|
||||
else
|
||||
(cd "$DIR/../" && printf "\n\n\n========== %s ==========\n\n\n" "${ENABLED_FEATURES:1}" && set -x && cargo build "${additional_flags[@]}" --no-default-features --features "${ENABLED_FEATURES:1}")
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
@@ -1,3 +1,4 @@
|
||||
#![feature(exit_status_error)]
|
||||
#![feature(round_char_boundary)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
use std::io::Read;
|
||||
|
||||
12
src/bin_wasm.rs
Normal file
12
src/bin_wasm.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use organic::wasm::wasm_parse_org;
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
|
||||
let rust_parsed = wasm_parse_org(org_contents);
|
||||
serde_wasm_bindgen::to_value(&rust_parsed).unwrap()
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
Ok(())
|
||||
}
|
||||
62
src/bin_wasm_test.rs
Normal file
62
src/bin_wasm_test.rs
Normal file
@@ -0,0 +1,62 @@
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(exit_status_error)]
|
||||
use std::io::Read;
|
||||
|
||||
use organic::wasm_test::wasm_run_anonymous_compare;
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
use crate::init_tracing::init_telemetry;
|
||||
#[cfg(feature = "tracing")]
|
||||
use crate::init_tracing::shutdown_telemetry;
|
||||
#[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()?;
|
||||
if wasm_run_anonymous_compare(org_contents).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)
|
||||
}
|
||||
@@ -2,15 +2,14 @@ use std::path::Path;
|
||||
|
||||
use crate::compare::diff::compare_document;
|
||||
use crate::compare::diff::DiffResult;
|
||||
use crate::compare::parse::emacs_parse_anonymous_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::context::GlobalSettings;
|
||||
use crate::context::LocalFileAccessInterface;
|
||||
use crate::parser::parse_file_with_settings;
|
||||
use crate::parser::parse_with_settings;
|
||||
use crate::util::emacs_parse_anonymous_org_document;
|
||||
use crate::util::emacs_parse_file_org_document;
|
||||
use crate::util::print_versions;
|
||||
|
||||
pub async fn run_anonymous_compare<P: AsRef<str>>(
|
||||
org_contents: P,
|
||||
@@ -128,12 +127,3 @@ pub async fn run_compare_on_file_with_settings<'g, 's, P: AsRef<Path>>(
|
||||
|
||||
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(())
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ mod compare_field;
|
||||
mod diff;
|
||||
mod elisp_fact;
|
||||
mod macros;
|
||||
mod parse;
|
||||
mod sexp;
|
||||
mod util;
|
||||
pub use compare::run_anonymous_compare;
|
||||
@@ -13,3 +12,4 @@ pub use compare::run_compare_on_file;
|
||||
pub use compare::run_compare_on_file_with_settings;
|
||||
pub use compare::silent_anonymous_compare;
|
||||
pub use compare::silent_compare_on_file;
|
||||
pub use sexp::sexp;
|
||||
|
||||
@@ -10,6 +10,12 @@ extern crate test;
|
||||
|
||||
#[cfg(feature = "compare")]
|
||||
pub mod compare;
|
||||
#[cfg(any(feature = "compare", feature = "wasm_test"))]
|
||||
pub mod util;
|
||||
#[cfg(any(feature = "wasm", feature = "wasm_test"))]
|
||||
pub mod wasm;
|
||||
#[cfg(feature = "wasm_test")]
|
||||
pub mod wasm_test;
|
||||
|
||||
mod context;
|
||||
mod error;
|
||||
|
||||
@@ -2,28 +2,53 @@ use std::path::Path;
|
||||
|
||||
use tokio::process::Command;
|
||||
|
||||
use crate::context::HeadlineLevelFilter;
|
||||
use crate::settings::GlobalSettings;
|
||||
use crate::settings::HeadlineLevelFilter;
|
||||
|
||||
/// Generate elisp to configure org-mode parsing settings
|
||||
///
|
||||
/// Currently only org-list-allow-alphabetical is supported.
|
||||
fn global_settings_elisp(global_settings: &GlobalSettings) -> String {
|
||||
// This string concatenation is wildly inefficient but its only called in tests 🤷.
|
||||
let mut ret = "".to_owned();
|
||||
if global_settings.list_allow_alphabetical {
|
||||
ret += "(setq org-list-allow-alphabetical t)\n"
|
||||
pub 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(())
|
||||
}
|
||||
if global_settings.tab_width != crate::settings::DEFAULT_TAB_WIDTH {
|
||||
ret += format!("(setq-default tab-width {})", global_settings.tab_width).as_str();
|
||||
|
||||
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)?)
|
||||
}
|
||||
if global_settings.odd_levels_only != HeadlineLevelFilter::default() {
|
||||
ret += match global_settings.odd_levels_only {
|
||||
HeadlineLevelFilter::Odd => "(setq org-odd-levels-only t)\n",
|
||||
HeadlineLevelFilter::OddEven => "(setq org-odd-levels-only nil)\n",
|
||||
};
|
||||
}
|
||||
ret
|
||||
|
||||
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)?)
|
||||
}
|
||||
|
||||
pub(crate) async fn emacs_parse_anonymous_org_document<'g, 's, C>(
|
||||
@@ -144,39 +169,23 @@ where
|
||||
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)?)
|
||||
/// Generate elisp to configure org-mode parsing settings
|
||||
///
|
||||
/// Currently only org-list-allow-alphabetical is supported.
|
||||
fn global_settings_elisp(global_settings: &GlobalSettings) -> String {
|
||||
// This string concatenation is wildly inefficient but its only called in tests 🤷.
|
||||
let mut ret = "".to_owned();
|
||||
if global_settings.list_allow_alphabetical {
|
||||
ret += "(setq org-list-allow-alphabetical t)\n"
|
||||
}
|
||||
|
||||
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)?)
|
||||
if global_settings.tab_width != crate::settings::DEFAULT_TAB_WIDTH {
|
||||
ret += format!("(setq-default tab-width {})", global_settings.tab_width).as_str();
|
||||
}
|
||||
if global_settings.odd_levels_only != HeadlineLevelFilter::default() {
|
||||
ret += match global_settings.odd_levels_only {
|
||||
HeadlineLevelFilter::Odd => "(setq org-odd-levels-only t)\n",
|
||||
HeadlineLevelFilter::OddEven => "(setq org-odd-levels-only nil)\n",
|
||||
};
|
||||
}
|
||||
ret
|
||||
}
|
||||
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 crate::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 crate::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 serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::macros::to_wasm;
|
||||
use super::standard_properties::WasmStandardProperties;
|
||||
use super::to_wasm::ToWasm;
|
||||
use crate::types::Bold;
|
||||
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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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,
|
||||
})
|
||||
}
|
||||
);
|
||||
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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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;
|
||||
68
src/wasm/mod.rs
Normal file
68
src/wasm/mod.rs
Normal file
@@ -0,0 +1,68 @@
|
||||
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;
|
||||
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 use parse_result::wasm_parse_org;
|
||||
pub 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 crate::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 crate::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 crate::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 serde::Serialize;
|
||||
|
||||
use super::document::WasmDocument;
|
||||
use super::ToWasm;
|
||||
use super::ToWasmContext;
|
||||
use crate::parser::parse_with_settings;
|
||||
use crate::settings::GlobalSettings;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "status", content = "content")]
|
||||
pub enum ParseResult<'s> {
|
||||
#[serde(rename = "success")]
|
||||
Success(WasmDocument<'s>),
|
||||
|
||||
#[serde(rename = "error")]
|
||||
Error(String),
|
||||
}
|
||||
|
||||
pub fn wasm_parse_org(org_contents: &str) -> ParseResult<'_> {
|
||||
let global_settings = GlobalSettings::default();
|
||||
let to_wasm_context = ToWasmContext::new(org_contents);
|
||||
let rust_parsed = match parse_with_settings(org_contents, &global_settings)
|
||||
.map(|document| document.to_wasm(to_wasm_context))
|
||||
.map(|wasm_document| match wasm_document {
|
||||
Ok(wasm_document) => ParseResult::Success(wasm_document),
|
||||
Err(err) => ParseResult::Error(format!("{:?}", err)),
|
||||
}) {
|
||||
Ok(wasm_document) => wasm_document,
|
||||
Err(err) => ParseResult::Error(format!("{:?}", err)),
|
||||
};
|
||||
rust_parsed
|
||||
}
|
||||
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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::types::PostBlank;
|
||||
use crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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 crate::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,
|
||||
})
|
||||
}
|
||||
);
|
||||
4
src/wasm_test/mod.rs
Normal file
4
src/wasm_test/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
mod runner;
|
||||
|
||||
pub use runner::wasm_run_anonymous_compare;
|
||||
pub use runner::wasm_run_anonymous_compare_with_settings;
|
||||
60
src/wasm_test/runner.rs
Normal file
60
src/wasm_test/runner.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use crate::compare::sexp;
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::parser::parse_with_settings;
|
||||
use crate::util::emacs_parse_anonymous_org_document;
|
||||
use crate::util::print_versions;
|
||||
use crate::wasm::ParseResult;
|
||||
use crate::wasm::ToWasm;
|
||||
use crate::wasm::ToWasmContext;
|
||||
|
||||
pub async fn wasm_run_anonymous_compare<P: AsRef<str>>(
|
||||
org_contents: P,
|
||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
wasm_run_anonymous_compare_with_settings(org_contents, &GlobalSettings::default(), false).await
|
||||
}
|
||||
|
||||
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 to_wasm_context = ToWasmContext::new(org_contents);
|
||||
let wasm_parsed = match rust_parsed.to_wasm(to_wasm_context) {
|
||||
Ok(wasm_document) => ParseResult::Success(wasm_document),
|
||||
Err(err) => ParseResult::Error(format!("{:?}", err)),
|
||||
};
|
||||
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);
|
||||
println!("{}", serde_json::to_string(&wasm_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)
|
||||
}
|
||||
Reference in New Issue
Block a user