From a74c6c9e5c67febf5f79b858682bcb097143e34e Mon Sep 17 00:00:00 2001 From: kitsunecafe <10284516+kitsunecafe@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:45:31 -0500 Subject: [PATCH] use plaintext highlighter if syntax not found --- src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index d762b95..4857efc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -88,7 +88,11 @@ impl<'a> Parse for SyntectParser<'a> { let file = String::from_utf8_lossy(src).to_string(); let result = CODE_BLOCK_RE .replace_all(file.as_str(), |captures: &Captures| { - let syntax = self.syntax_set.find_syntax_by_token(&captures[1]).unwrap(); + let syntax = self + .syntax_set + .find_syntax_by_token(&captures[1]) + .unwrap_or(self.syntax_set.find_syntax_plain_text()); + highlighted_html_for_string( &captures[2], &self.syntax_set,