diff options
author | gennyble <gen@nyble.dev> | 2024-04-13 05:40:17 -0500 |
---|---|---|
committer | gennyble <gen@nyble.dev> | 2024-04-13 05:40:17 -0500 |
commit | fafb3c3ceaa16e93f69b38e33e64e240573e4875 (patch) | |
tree | c49c9eb94e6c14c089847c02ba156d5566e5b118 /src/markup.rs | |
parent | 1b93aecbdc261ca2f7932db2754c6e33487dd9c8 (diff) | |
download | awake-fafb3c3ceaa16e93f69b38e33e64e240573e4875.tar.gz awake-fafb3c3ceaa16e93f69b38e33e64e240573e4875.zip |
:)
Diffstat (limited to 'src/markup.rs')
-rw-r--r-- | src/markup.rs | 15 |
1 files changed, 10 insertions, 5 deletions
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 = "\\<i>test</i>"; + let correct = "<p>\n<i>test</i>\n</p>"; + assert_eq!(process(str), correct) + } + const BASE: &str = "test/markup"; fn test_files(test: &str) { let input_path = format!("{BASE}/{test}/input.html"); |