use plaintext highlighter if syntax not found

This commit is contained in:
kitsunecafe 2024-02-19 17:45:31 -05:00
parent 4a872d3642
commit a74c6c9e5c
1 changed files with 5 additions and 1 deletions

View File

@ -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,