Compare commits

...

5 Commits

Author SHA1 Message Date
Tom Alexander
3ec900c8df
Implement latex fragment.
Some checks failed
clippy Build clippy has failed
rust-build Build rust-build has failed
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-test Build rust-test has failed
2023-12-30 13:00:07 -05:00
Tom Alexander
d0a008ed22
Implement org macro. 2023-12-30 13:00:07 -05:00
Tom Alexander
f2292f1c07
Implement target. 2023-12-30 12:22:23 -05:00
Tom Alexander
44392cfcca
Implement radio target. 2023-12-30 12:17:04 -05:00
Tom Alexander
110630d230
Implement radio link and regular link. 2023-12-30 12:14:03 -05:00
7 changed files with 85 additions and 35 deletions

View File

@ -4,15 +4,13 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::LatexFragment; use crate::types::LatexFragment;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct WasmLatexFragment { pub struct WasmLatexFragment {
#[serde(flatten)] pub(crate) value: String,
pub(crate) additional_properties: AdditionalProperties,
} }
to_wasm!( to_wasm!(
@ -21,12 +19,12 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::LatexFragment(original) }, { WasmAstNode::LatexFragment(original) },
{ "TODO".into() }, { "latex-fragment".into() },
{ {
Ok(( Ok((
Vec::new(), Vec::new(),
WasmLatexFragment { WasmLatexFragment {
additional_properties: AdditionalProperties::default(), value: original.value.to_owned(),
}, },
)) ))
} }

View File

@ -4,15 +4,15 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::OrgMacro; use crate::types::OrgMacro;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct WasmOrgMacro { pub struct WasmOrgMacro {
#[serde(flatten)] pub(crate) key: String,
pub(crate) additional_properties: AdditionalProperties, pub(crate) value: String,
pub(crate) args: Vec<String>,
} }
to_wasm!( to_wasm!(
@ -21,12 +21,14 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::OrgMacro(original) }, { WasmAstNode::OrgMacro(original) },
{ "TODO".into() }, { "macro".into() },
{ {
Ok(( Ok((
Vec::new(), Vec::new(),
WasmOrgMacro { WasmOrgMacro {
additional_properties: AdditionalProperties::default(), key: original.key.to_lowercase(),
value: original.value.to_owned(),
args: original.get_args().map(|s| s.into_owned()).collect(),
}, },
)) ))
} }

View File

@ -4,15 +4,23 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::LinkType;
use crate::types::PlainLink; use crate::types::PlainLink;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "format")]
#[serde(rename = "plain")]
pub struct WasmPlainLink { pub struct WasmPlainLink {
#[serde(flatten)] #[serde(rename = "type")]
pub(crate) additional_properties: AdditionalProperties, pub(crate) link_type: String,
pub(crate) path: String,
#[serde(rename = "raw-link")]
pub(crate) raw_link: String,
pub(crate) application: Option<String>,
#[serde(rename = "search-option")]
pub(crate) search_option: Option<String>,
} }
to_wasm!( to_wasm!(
@ -21,12 +29,23 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::PlainLink(original) }, { WasmAstNode::PlainLink(original) },
{ "TODO".into() }, { "link".into() },
{ {
Ok(( Ok((
Vec::new(), Vec::new(),
WasmPlainLink { WasmPlainLink {
additional_properties: AdditionalProperties::default(), link_type: match &original.link_type {
LinkType::File => "file".to_owned(),
LinkType::Protocol(protocol) => protocol.clone().into_owned(),
LinkType::Id => "id".to_owned(),
LinkType::CustomId => "custom-id".to_owned(),
LinkType::CodeRef => "coderef".to_owned(),
LinkType::Fuzzy => "fuzzy".to_owned(),
},
path: original.path.to_owned(),
raw_link: original.raw_link.to_owned(),
application: original.application.map(str::to_owned),
search_option: original.search_option.map(str::to_owned),
}, },
)) ))
} }

View File

@ -4,15 +4,22 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::RadioLink; use crate::types::RadioLink;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "format")]
#[serde(rename = "plain")]
pub struct WasmRadioLink { pub struct WasmRadioLink {
#[serde(flatten)] #[serde(rename = "type")]
pub(crate) additional_properties: AdditionalProperties, pub(crate) link_type: String,
pub(crate) path: String,
#[serde(rename = "raw-link")]
pub(crate) raw_link: String,
pub(crate) application: Option<String>, // Always None
#[serde(rename = "search-option")]
pub(crate) search_option: Option<String>, // Always None
} }
to_wasm!( to_wasm!(
@ -21,7 +28,7 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::RadioLink(original) }, { WasmAstNode::RadioLink(original) },
{ "TODO".into() }, { "link".into() },
{ {
let children = original let children = original
.children .children
@ -36,7 +43,11 @@ to_wasm!(
Ok(( Ok((
children, children,
WasmRadioLink { WasmRadioLink {
additional_properties: AdditionalProperties::default(), link_type: "radio".to_owned(),
path: original.path.to_owned(),
raw_link: original.get_raw_link().to_owned(),
application: None,
search_option: None,
}, },
)) ))
} }

View File

@ -4,15 +4,13 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::RadioTarget; use crate::types::RadioTarget;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct WasmRadioTarget { pub struct WasmRadioTarget {
#[serde(flatten)] pub(crate) value: String,
pub(crate) additional_properties: AdditionalProperties,
} }
to_wasm!( to_wasm!(
@ -21,7 +19,7 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::RadioTarget(original) }, { WasmAstNode::RadioTarget(original) },
{ "TODO".into() }, { "radio-target".into() },
{ {
let children = original let children = original
.children .children
@ -36,7 +34,7 @@ to_wasm!(
Ok(( Ok((
children, children,
WasmRadioTarget { WasmRadioTarget {
additional_properties: AdditionalProperties::default(), value: original.value.to_owned(),
}, },
)) ))
} }

View File

@ -1,18 +1,28 @@
use std::borrow::Cow;
use serde::Deserialize; use serde::Deserialize;
use serde::Serialize; use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::LinkType;
use crate::types::RegularLink; use crate::types::RegularLink;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "format")]
#[serde(rename = "bracket")]
pub struct WasmRegularLink { pub struct WasmRegularLink {
#[serde(flatten)] #[serde(rename = "type")]
pub(crate) additional_properties: AdditionalProperties, pub(crate) link_type: String,
pub(crate) path: String,
#[serde(rename = "raw-link")]
pub(crate) raw_link: String,
pub(crate) application: Option<String>,
#[serde(rename = "search-option")]
pub(crate) search_option: Option<String>,
} }
to_wasm!( to_wasm!(
@ -21,7 +31,7 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::RegularLink(original) }, { WasmAstNode::RegularLink(original) },
{ "TODO".into() }, { "link".into() },
{ {
let children = original let children = original
.children .children
@ -36,7 +46,21 @@ to_wasm!(
Ok(( Ok((
children, children,
WasmRegularLink { WasmRegularLink {
additional_properties: AdditionalProperties::default(), link_type: match &original.link_type {
LinkType::File => "file".to_owned(),
LinkType::Protocol(protocol) => protocol.clone().into_owned(),
LinkType::Id => "id".to_owned(),
LinkType::CustomId => "custom-id".to_owned(),
LinkType::CodeRef => "coderef".to_owned(),
LinkType::Fuzzy => "fuzzy".to_owned(),
},
path: original.get_path().into_owned(),
raw_link: original.get_raw_link().into_owned(),
application: original
.application
.as_ref()
.map(|c| c.clone().into_owned()),
search_option: original.get_search_option().map(Cow::into_owned),
}, },
)) ))
} }

View File

@ -4,15 +4,13 @@ use serde::Serialize;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact; use crate::compare::ElispFact;
use crate::types::Target; use crate::types::Target;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct WasmTarget { pub struct WasmTarget {
#[serde(flatten)] pub(crate) value: String,
pub(crate) additional_properties: AdditionalProperties,
} }
to_wasm!( to_wasm!(
@ -21,12 +19,12 @@ to_wasm!(
original, original,
wasm_context, wasm_context,
{ WasmAstNode::Target(original) }, { WasmAstNode::Target(original) },
{ "TODO".into() }, { "target".into() },
{ {
Ok(( Ok((
Vec::new(), Vec::new(),
WasmTarget { WasmTarget {
additional_properties: AdditionalProperties::default(), value: original.value.to_owned(),
}, },
)) ))
} }