about summary refs log tree commit diff
path: root/src/markup.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/markup.rs')
-rw-r--r--src/markup.rs15
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");