Skip to content

Commit

Permalink
Handle \r\n
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Jun 17, 2024
1 parent f2267a4 commit 37a17cd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/syntax-highlighting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ impl Object for Highlighter {
"call block did not return a string",
)
})?;
if let Some(rest) = content_str.strip_prefix('\n') {
content_str = rest;
for prefix in ['\r', '\n'] {
if let Some(rest) = content_str.strip_prefix(prefix) {
content_str = rest;
}
}
let syntax = self.ss.find_syntax_by_token(lang).ok_or_else(|| {
Error::new(
Expand Down

0 comments on commit 37a17cd

Please sign in to comment.