Skip to content

Commit

Permalink
detect front matter delim at EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
charlottia committed Dec 14, 2024
1 parent 8848a96 commit 4b90053
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,16 @@ pub fn split_off_front_matter<'s>(mut s: &'s str, delimiter: &str) -> Option<(&'
start += match s[start..]
.find(&("\n".to_string() + delimiter + "\r\n"))
.or_else(|| s[start..].find(&("\n".to_string() + delimiter + "\n")))
.or_else(|| s[start..].find(&("\n".to_string() + delimiter))) // delimiter followed by EOF
{
Some(n) => n + 1 + delimiter.len(),
None => return None,
};

if start == s.len() {
return Some((s, ""));
}

start += if s[start..].starts_with('\n') {
1
} else if s[start..].starts_with("\r\n") {
Expand Down

0 comments on commit 4b90053

Please sign in to comment.