chore(native): run cargo fmt

Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
Amogh Lele 2021-08-17 03:24:30 +05:30
parent 92146cd3dc
commit 816332bdd6
No known key found for this signature in database
GPG Key ID: ED5C54FBBB920E51

View File

@ -1,4 +1,8 @@
use syntect::{html::{ClassStyle, ClassedHTMLGenerator}, parsing::SyntaxSet, util::LinesWithEndings}; use syntect::{
html::{ClassStyle, ClassedHTMLGenerator},
parsing::SyntaxSet,
util::LinesWithEndings,
};
#[rustler::nif] #[rustler::nif]
fn add(a: i64, b: i64) -> i64 { fn add(a: i64, b: i64) -> i64 {
@ -7,20 +11,20 @@ fn add(a: i64, b: i64) -> i64 {
#[rustler::nif] #[rustler::nif]
pub fn highlight_text(text: String, lang: String) -> String { pub fn highlight_text(text: String, lang: String) -> String {
let syntax_set = SyntaxSet::load_defaults_newlines(); let syntax_set = SyntaxSet::load_defaults_newlines();
let syntax = syntax_set let syntax = syntax_set
.find_syntax_by_extension(&lang) .find_syntax_by_extension(&lang)
.unwrap_or(syntax_set.find_syntax_plain_text()); .unwrap_or(syntax_set.find_syntax_plain_text());
let mut rs_html_generator = let mut rs_html_generator =
ClassedHTMLGenerator::new_with_class_style(syntax, &syntax_set, ClassStyle::Spaced); ClassedHTMLGenerator::new_with_class_style(syntax, &syntax_set, ClassStyle::Spaced);
for line in LinesWithEndings::from(&text) { for line in LinesWithEndings::from(&text) {
rs_html_generator.parse_html_for_line_which_includes_newline(&line) rs_html_generator.parse_html_for_line_which_includes_newline(&line)
} }
rs_html_generator.finalize() rs_html_generator.finalize()
} }
rustler::init!("Elixir.Ketbin.Utils.Syntax", [add, highlight_text]); rustler::init!("Elixir.Ketbin.Utils.Syntax", [add, highlight_text]);