use plaintext highlighter if syntax not found
This commit is contained in:
parent
4a872d3642
commit
a74c6c9e5c
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue