From 210978762589f6c47f4d734e92e0a62c0f60dba5 Mon Sep 17 00:00:00 2001 From: William Yao Date: Tue, 20 Jun 2017 00:42:56 -0500 Subject: [PATCH] coalesce syntect data structures into rendering::highlighting (Keats/gutenberg#89) --- src/rendering/highlighting.rs | 10 ++++++++++ src/rendering/markdown.rs | 3 +-- src/rendering/mod.rs | 1 - src/rendering/parsing.rs | 10 ---------- 4 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 src/rendering/parsing.rs diff --git a/src/rendering/highlighting.rs b/src/rendering/highlighting.rs index ee2d95b8..973b23fb 100644 --- a/src/rendering/highlighting.rs +++ b/src/rendering/highlighting.rs @@ -1,6 +1,16 @@ use syntect::dumps::from_binary; +use syntect::parsing::SyntaxSet; use syntect::highlighting::ThemeSet; +thread_local!{ + pub static SYNTAX_SET: SyntaxSet = { + let mut ss: SyntaxSet = from_binary(include_bytes!("../../sublime_syntaxes/newlines.packdump")); + ss.link_syntaxes(); + ss + }; +} + lazy_static!{ pub static ref THEME_SET: ThemeSet = from_binary(include_bytes!("../../sublime_themes/all.themedump")); } + diff --git a/src/rendering/markdown.rs b/src/rendering/markdown.rs index a4288055..590e1656 100644 --- a/src/rendering/markdown.rs +++ b/src/rendering/markdown.rs @@ -12,8 +12,7 @@ use errors::{Result}; use site::resolve_internal_link; use front_matter::InsertAnchor; use rendering::context::Context; -use rendering::highlighting::THEME_SET; -use rendering::parsing::SYNTAX_SET; +use rendering::highlighting::{SYNTAX_SET, THEME_SET}; use rendering::short_code::{ShortCode, parse_shortcode, render_simple_shortcode}; use content::{TempHeader, Header, make_table_of_contents}; diff --git a/src/rendering/mod.rs b/src/rendering/mod.rs index b51351bb..53b696d5 100644 --- a/src/rendering/mod.rs +++ b/src/rendering/mod.rs @@ -1,5 +1,4 @@ pub mod highlighting; -pub mod parsing; pub mod markdown; pub mod short_code; pub mod context; diff --git a/src/rendering/parsing.rs b/src/rendering/parsing.rs deleted file mode 100644 index 9ff5e5fb..00000000 --- a/src/rendering/parsing.rs +++ /dev/null @@ -1,10 +0,0 @@ -use syntect::parsing::SyntaxSet; -use syntect::dumps::from_binary; - -thread_local! { - pub static SYNTAX_SET: SyntaxSet = { - let mut ss: SyntaxSet = from_binary(include_bytes!("../../sublime_syntaxes/newlines.packdump")); - ss.link_syntaxes(); - ss - }; -}