Skip to content

Commit

Permalink
Fix errors when rendering pages with CRLF line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
acuteenvy committed Nov 16, 2023
1 parent 297aedd commit ca1bce7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ impl<'a> PageRenderer<'a> {
self.current_line
.strip_prefix(EXAMPLE)
.unwrap()
.strip_suffix("`\n")
.trim_end()
.strip_suffix('`')
.ok_or_else(|| {
Error::parse_page(self.path, self.lnum, &self.current_line)
.describe("\nEvery line with an example must end with a backtick '`'.")
Expand Down Expand Up @@ -280,7 +281,7 @@ impl<'a> PageRenderer<'a> {
self.add_bullet()?;
} else if self.current_line.starts_with(EXAMPLE) {
self.add_example()?;
} else if self.current_line == "\n" {
} else if self.current_line.chars().all(char::is_whitespace) {
self.add_newline()?;
} else {
return Err(
Expand Down

0 comments on commit ca1bce7

Please sign in to comment.