Skip to content

Commit

Permalink
feat(Rust): Internally encode nodes to HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Jun 7, 2021
1 parent 8dcd2af commit de11fc9
Show file tree
Hide file tree
Showing 6 changed files with 933 additions and 0 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"Pyla",
"Rscript",
"Stencila",
"itemprop",
"itemscope",
"itemtype",
"schemars",
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ inspect = []

format-json = []
format-yaml = ["serde_yaml"]
format-html = ["html-escape"]

query-jsonptr = [] #"json-pointer"]
query-jmespath = [] #"jmespatch"]
Expand Down Expand Up @@ -76,6 +77,7 @@ default = [
"inspect",
"format-json",
"format-yaml",
"format-html",
"query-jsonptr",
"query-jmespath",
"template-handlebars",
Expand All @@ -95,6 +97,7 @@ futures = "0.3.15"
gitignore = "1.0.7"
glob = "0.3.0"
handlebars = { version = "4.0.0", optional = true }
html-escape = { version = "0.2.9", optional = true }
humantime = { version = "2.1.0", optional = true }
ignore = "0.4.17"
jsonschema = { version = "0.9.0", optional = true }
Expand Down
1 change: 1 addition & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub mod methods {

pub mod decode;
pub mod encode;
pub mod encode_html;

pub mod export;
pub mod import;
Expand Down
6 changes: 6 additions & 0 deletions rust/src/methods/encode.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::encode_html::encode_html;
use crate::plugins;
use eyre::{bail, Result};
use stencila_schema::Node;
Expand All @@ -8,8 +9,13 @@ pub async fn encode(node: Node, format: &str) -> Result<String> {
let content = match format {
#[cfg(feature = "format-json")]
"json" => serde_json::to_string(&node)?,

#[cfg(feature = "format-yaml")]
"yaml" => serde_yaml::to_string(&node)?,

#[cfg(feature = "format-html")]
"html" => encode_html(&node)?,

_ => {
#[cfg(feature = "request")]
{
Expand Down

0 comments on commit de11fc9

Please sign in to comment.