From fafb3c3ceaa16e93f69b38e33e64e240573e4875 Mon Sep 17 00:00:00 2001 From: gennyble Date: Sat, 13 Apr 2024 05:40:17 -0500 Subject: :) --- src/markup.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/markup.rs') diff --git a/src/markup.rs b/src/markup.rs index 4e0d66e..a1516f4 100644 --- a/src/markup.rs +++ b/src/markup.rs @@ -47,12 +47,12 @@ impl State { let escaped = self.escape_line(line); self.current.push_str(escaped); + + self.last_blank = false; } else { // line is empty. self.push_current(); } - - self.last_blank = false; } pub fn done(mut self) -> String { @@ -62,7 +62,7 @@ impl State { fn escape_line<'a>(&mut self, line: &'a str) -> &'a str { if let Some(strip) = line.strip_prefix('\\') { - match line.chars().next() { + match strip.chars().next() { Some('[') => strip, Some('<') => { if self.last_blank { @@ -157,8 +157,6 @@ pub fn process(raw: &str) -> String { #[cfg(test)] mod test { - use camino::Utf8PathBuf; - use crate::markup::process; #[test] @@ -200,6 +198,13 @@ mod test { assert_eq!(process(str), correct) } + #[test] + fn wraps_escaped_html() { + let str = "\\test"; + let correct = "

\ntest\n

"; + assert_eq!(process(str), correct) + } + const BASE: &str = "test/markup"; fn test_files(test: &str) { let input_path = format!("{BASE}/{test}/input.html"); -- cgit 1.4.1-3-g733a5