about summary refs log tree commit diff
path: root/markup/src
diff options
context:
space:
mode:
authorgennyble <gen@nyble.dev>2026-09-21 14:41:39 -0500
committergennyble <gen@nyble.dev>2026-09-21 14:41:39 -0500
commitb5a655d89e8075ffc40725e990bc5c863b4e5411 (patch)
treec4f05b66b05f407b973ee896bdd9a27325ea2bbb /markup/src
parentde0e60603d3e470befad49f2ec59778b5d1b5d59 (diff)
markup
Diffstat (limited to 'markup/src')
-rw-r--r--markup/src/legacy/intra.rs (renamed from markup/src/intra.rs)5
-rw-r--r--markup/src/legacy/mod.rs104
-rwxr-xr-xmarkup/src/legacy/state.rs (renamed from markup/src/state.rs)19
-rw-r--r--markup/src/lib.rs107
-rw-r--r--markup/src/lineup/mod.rs2
-rw-r--r--markup/src/lineup/tree.rs4
6 files changed, 112 insertions, 129 deletions
diff --git a/markup/src/intra.rs b/markup/src/legacy/intra.rs
index e936e39..6a23ee5 100644
--- a/markup/src/intra.rs
+++ b/markup/src/legacy/intra.rs
@@ -1,6 +1,4 @@
-use core::range;
 use std::fmt::Display;
-use std::ops::RangeInclusive;
 
 macro_rules! false_or_continue {
 	($action:expr) => {
@@ -48,6 +46,7 @@ fn escaped_char(ctx: &mut Context, ch: char) -> bool {
 			ctx.push_char(ch);
 			true
 		} else {
+			ctx.push_char('\\');
 			false
 		}
 	} else if ch == '\\' {
@@ -255,7 +254,7 @@ impl Default for State {
 // MARK: tests
 #[cfg(test)]
 mod test {
-	use crate::intra::process;
+	use super::process;
 
 	macro_rules! verify {
 		($inp:literal -> $out:literal) => {{
diff --git a/markup/src/legacy/mod.rs b/markup/src/legacy/mod.rs
new file mode 100644
index 0000000..562b877
--- /dev/null
+++ b/markup/src/legacy/mod.rs
@@ -0,0 +1,104 @@
+mod intra;
+mod state;
+
+use std::ops::Deref;
+
+use bempline::{Document, Options};
+
+use state::State;
+
+pub fn process(raw: &str) -> Markup {
+	let mut state = State::default();
+
+	for line in raw.lines() {
+		state.process_line(line)
+	}
+
+	state.done()
+}
+
+pub struct Markup {
+	content: String,
+	fill: Vec<Fill>,
+}
+
+impl Markup {
+	pub fn fill(&self) -> &[Fill] {
+		&self.fill
+	}
+
+	pub fn content(&self) -> &str {
+		&self.content
+	}
+
+	pub fn into_content(self) -> String {
+		self.content
+	}
+
+	pub fn into_document(self) -> Result<Document, String> {
+		let Ok(mut doc) = Document::from_str(&self.content, Options::default()) else {
+			return Err(self.content);
+		};
+
+		self.fill_document(&mut doc);
+
+		Ok(doc)
+	}
+
+	pub fn fill_document(&self, doc: &mut Document) {
+		for fill in &self.fill {
+			doc.set(&fill.key, &fill.content);
+		}
+	}
+}
+
+impl Deref for Markup {
+	type Target = String;
+
+	fn deref(&self) -> &Self::Target {
+		&self.content
+	}
+}
+
+#[derive(Clone, Debug, PartialEq)]
+pub struct Fill {
+	pub key: String,
+	pub content: String,
+}
+
+#[cfg(test)]
+mod document_test {
+	use crate::legacy::process;
+
+	const BASE: &str = "test/markup";
+	fn test_files(test: &str) {
+		let input_path = format!("{BASE}/{test}/input.html");
+		let output_path = format!("{BASE}/{test}/output.html");
+
+		let input = std::fs::read_to_string(input_path).unwrap();
+		let output = std::fs::read_to_string(output_path).unwrap();
+
+		let actual = process(&input).into_document().unwrap().compile();
+
+		assert_eq!(actual, output)
+	}
+
+	#[test]
+	fn inserts_fill() {
+		let input = "[@fill main]\nwords!\n[@fill-end]\n{main}";
+		let expected = "<p>\nwords!\n</p>";
+		let markup = process(input);
+		let doc = markup.into_document().unwrap().compile();
+		assert_eq!(doc, expected)
+	}
+
+	#[test]
+	fn fill_restores_paragraphs() {
+		test_files("fill paragraphs");
+	}
+
+	#[test]
+	fn parses_complicated_fill() {
+		test_files("complicated fill");
+	}
+}
diff --git a/markup/src/state.rs b/markup/src/legacy/state.rs
index 64522b6..35472e3 100755
--- a/markup/src/state.rs
+++ b/markup/src/legacy/state.rs
@@ -1,6 +1,4 @@
-use std::{cell::RefCell, rc::Rc};
-
-use crate::{Fill, InterlinkSolver, Markup, intra, lineup::EchoInterlinkSolver};
+use crate::legacy::{Fill, Markup, intra};
 
 pub(crate) struct State {
 	active_id: Option<String>,
@@ -12,8 +10,6 @@ pub(crate) struct State {
 	fills: Vec<Fill>,
 	escaped_html: bool,
 	last_blank: bool,
-
-	solver: Rc<dyn InterlinkSolver>,
 }
 
 impl Default for State {
@@ -28,8 +24,6 @@ impl Default for State {
 			fills: vec![],
 			escaped_html: false,
 			last_blank: true,
-
-			solver: Rc::new(EchoInterlinkSolver),
 		}
 	}
 }
@@ -84,15 +78,6 @@ impl State {
 			&& (!string.starts_with('<') || (string.starts_with('<') && self.escaped_html))
 	}
 
-	pub fn with_interlink_solver<Solver: InterlinkSolver + 'static>(
-		mut self,
-		solver: Solver,
-	) -> Self {
-		self.solver = Rc::new(solver);
-
-		self
-	}
-
 	pub fn process_line(&mut self, line: &str) {
 		if self.parse_command(line) {
 			// Don't set last_blank; a command does not break up a text block
@@ -243,7 +228,7 @@ struct FillComand {
 
 #[cfg(test)]
 mod test {
-	use crate::{Fill, process};
+	use crate::legacy::{Fill, process};
 
 	#[test]
 	fn parses_no_commands() {
diff --git a/markup/src/lib.rs b/markup/src/lib.rs
index 7add951..c224ad7 100644
--- a/markup/src/lib.rs
+++ b/markup/src/lib.rs
@@ -1,107 +1,2 @@
-mod breakdown;
-mod intra;
+pub mod legacy;
 pub mod lineup;
-mod state;
-
-use std::ops::Deref;
-
-use bempline::{Document, Options};
-
-use crate::state::State;
-pub use lineup::InterlinkSolver;
-
-pub fn process(raw: &str) -> Markup {
-	let mut state = State::default();
-
-	for line in raw.lines() {
-		state.process_line(line)
-	}
-
-	state.done()
-}
-
-pub struct Markup {
-	content: String,
-	fill: Vec<Fill>,
-}
-
-impl Markup {
-	pub fn fill(&self) -> &[Fill] {
-		&self.fill
-	}
-
-	pub fn content(&self) -> &str {
-		&self.content
-	}
-
-	pub fn into_content(self) -> String {
-		self.content
-	}
-
-	pub fn into_document(self) -> Result<Document, String> {
-		let Ok(mut doc) = Document::from_str(&self.content, Options::default()) else {
-			return Err(self.content);
-		};
-
-		self.fill_document(&mut doc);
-
-		Ok(doc)
-	}
-
-	pub fn fill_document(&self, doc: &mut Document) {
-		for fill in &self.fill {
-			doc.set(&fill.key, &fill.content);
-		}
-	}
-}
-
-impl Deref for Markup {
-	type Target = String;
-
-	fn deref(&self) -> &Self::Target {
-		&self.content
-	}
-}
-
-#[derive(Clone, Debug, PartialEq)]
-pub struct Fill {
-	pub key: String,
-	pub content: String,
-}
-
-#[cfg(test)]
-mod document_test {
-	use crate::process;
-
-	const BASE: &str = "test/markup";
-	fn test_files(test: &str) {
-		let input_path = format!("{BASE}/{test}/input.html");
-		let output_path = format!("{BASE}/{test}/output.html");
-
-		let input = std::fs::read_to_string(input_path).unwrap();
-		let output = std::fs::read_to_string(output_path).unwrap();
-
-		let actual = process(&input).into_document().unwrap().compile();
-
-		assert_eq!(actual, output)
-	}
-
-	#[test]
-	fn inserts_fill() {
-		let input = "[@fill main]\nwords!\n[@fill-end]\n{main}";
-		let expected = "<p>\nwords!\n</p>";
-		let markup = process(input);
-		let doc = markup.into_document().unwrap().compile();
-		assert_eq!(doc, expected)
-	}
-
-	#[test]
-	fn fill_restores_paragraphs() {
-		test_files("fill paragraphs");
-	}
-
-	#[test]
-	fn parses_complicated_fill() {
-		test_files("complicated fill");
-	}
-}
diff --git a/markup/src/lineup/mod.rs b/markup/src/lineup/mod.rs
index 0e1ecce..9545222 100644
--- a/markup/src/lineup/mod.rs
+++ b/markup/src/lineup/mod.rs
@@ -234,7 +234,7 @@ fn round3_intralevel<'raw, 'tok>(
 			}};
 		}
 
-		if let Token::Text(str) = tok.tok {
+		if let Token::Text(_) = tok.tok {
 			decay!()
 		}
 
diff --git a/markup/src/lineup/tree.rs b/markup/src/lineup/tree.rs
index dcb1cb4..bf81545 100644
--- a/markup/src/lineup/tree.rs
+++ b/markup/src/lineup/tree.rs
@@ -1,6 +1,6 @@
 use std::{borrow::Cow, rc::Rc};
 
-use crate::InterlinkSolver;
+use crate::lineup::InterlinkSolver;
 
 pub struct Document<'raw> {
 	pub(crate) nodes: Vec<TreeNode<'raw>>,
@@ -66,7 +66,7 @@ impl<'raw> TreeNode<'raw> {
 				Cow::Owned(format!("<a href=\"{location}\">{title}</a>"))
 			}
 			TreeNode::Link {
-				kind,
+				kind: _,
 				name,
 				children,
 			} => {