From 5c29835f70178e64daeae9b82111fe31376f6f35 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Sun, 1 Sep 2024 04:26:32 -0600 Subject: Allow escaping characters This patch adds the '\' character as a new rune, Rune::Special. This is for escaping special characters. Also works in strings (", '). Signed-off-by: Rory Dudley --- src/poem/read.rs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/poem/read.rs') diff --git a/src/poem/read.rs b/src/poem/read.rs index 8f3fd4a..7f3ae32 100644 --- a/src/poem/read.rs +++ b/src/poem/read.rs @@ -243,6 +243,7 @@ impl Readable for Poem { // Determine the meter based on the character let rune = match c { ' ' => Rune::Pause, + '\\' => Rune::Special, '/' => Rune::Path, '#' => Rune::Remark, '\'' | '"' => Rune::String, @@ -356,6 +357,14 @@ impl Readable for Poem { verse.add(&mut word, channel); } + Rune::Special => { + let c = chars.next(); + match c { + Some(c) => word.push(c), + None => continue, + } + } + Rune::Remark => { remark!(chars); } -- cgit v1.2.3