diff --git a/orgize-demos/Cargo.toml b/orgize-demos/Cargo.toml
index 81efc74..2aef164 100644
--- a/orgize-demos/Cargo.toml
+++ b/orgize-demos/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2018"
publish = false
[dependencies]
-actix-web = { version = "1.0.7", default-features = false }
+actix-web = { version = "1.0.8", default-features = false }
orgize = { path = "../orgize", features = ["syntect"] }
-serde = { version = "1.0.100", features = ["derive"] }
-serde_json = "1.0.40"
+serde = { version = "1.0.101", features = ["derive"] }
+serde_json = "1.0.41"
diff --git a/orgize-demos/src/main.rs b/orgize-demos/src/main.rs
index 325589d..f4b7228 100644
--- a/orgize-demos/src/main.rs
+++ b/orgize-demos/src/main.rs
@@ -4,22 +4,46 @@ use serde::Deserialize;
use std::env;
use std::io::Result;
-use orgize::export::html::SyntectHtmlHandler;
+use orgize::export::html::{DefaultHtmlHandler, SyntectHtmlHandler};
+use orgize::syntect::html::IncludeBackground;
#[get("/")]
fn index() -> HttpResponse {
HttpResponse::Ok().content_type("text/html").body(
- "
\
- ",
+ r#"
+"#,
)
}
@@ -27,6 +51,8 @@ fn index() -> HttpResponse {
struct FormData {
format: String,
content: String,
+ theme: String,
+ background: String,
}
#[post("/export")]
@@ -43,10 +69,31 @@ fn export(form: web::Form) -> Result {
.content_type("text/html")
.body(String::from_utf8(writer).unwrap()))
}
- "html-with-highlight" => {
+ "syntect" => {
+ let mut handler = SyntectHtmlHandler::new(DefaultHtmlHandler);
+
+ match &*form.theme {
+ "InspiredGitHub"
+ | "base16-ocean.dark"
+ | "base16-eighties.dark"
+ | "base16-mocha.dark"
+ | "base16-ocean.light"
+ | "Solarized (dark)"
+ | "Solarized (light)" => handler.theme = form.theme.clone(),
+ _ => return Ok(HttpResponse::BadRequest().body("Unsupported theme".to_string())),
+ }
+
+ match &*form.background {
+ "yes" => handler.background = IncludeBackground::Yes,
+ "no" => handler.background = IncludeBackground::No,
+ _ => {
+ return Ok(HttpResponse::BadRequest().body("Unsupported background".to_string()))
+ }
+ }
+
let mut writer = Vec::new();
- let mut handler = SyntectHtmlHandler::default();
org.html_with_handler(&mut writer, &mut handler)?;
+
Ok(HttpResponse::Ok()
.content_type("text/html")
.body(String::from_utf8(writer).unwrap()))