File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -87,12 +87,13 @@ impl<'a> MarkdownRenderer<'a> {
87
87
// Tweak annotations of code blocks.
88
88
iter_nodes ( root, & |node| {
89
89
if let NodeValue :: CodeBlock ( ref mut ncb) = node. data . borrow_mut ( ) . value {
90
- let mut orig_annot = String :: from_utf8 ( ncb. info . to_vec ( ) ) . unwrap ( ) ;
91
-
92
- // Ignore characters after a comma for syntax highlighting to work correctly.
93
- if let Some ( offset) = orig_annot. find ( ',' ) {
94
- let _ = orig_annot. drain ( offset..orig_annot. len ( ) ) ;
95
- ncb. info = orig_annot. as_bytes ( ) . to_vec ( ) ;
90
+ // If annot includes invalid UTF-8 char, do nothing.
91
+ if let Ok ( mut orig_annot) = String :: from_utf8 ( ncb. info . to_vec ( ) ) {
92
+ // Ignore characters after a comma for syntax highlighting to work correctly.
93
+ if let Some ( offset) = orig_annot. find ( ',' ) {
94
+ let _ = orig_annot. drain ( offset..orig_annot. len ( ) ) ;
95
+ ncb. info = orig_annot. as_bytes ( ) . to_vec ( ) ;
96
+ }
96
97
}
97
98
}
98
99
} ) ;
You can’t perform that action at this time.
0 commit comments