summaryrefslogtreecommitdiffstats
path: root/src/poem/read.rs
diff options
context:
space:
mode:
authorRory Dudley2024-09-01 04:24:41 -0600
committerRory Dudley2024-09-01 04:24:41 -0600
commitd03b4643c9c4f85c642182da7a56a613b6f819d4 (patch)
tree8b82edaa874486fe46a12a25e408f796f8a5d875 /src/poem/read.rs
parent6328666624e59574946f7af1570c5676aa54d0ac (diff)
downloaddwarvish-d03b4643c9c4f85c642182da7a56a613b6f819d4.tar.gz
Allow escaping characters
This patch adds the '\' character as a new rune, Rune::Special. This is for escaping special characters. Also works in strings (", ').
Diffstat (limited to 'src/poem/read.rs')
-rw-r--r--src/poem/read.rs9
1 files changed, 9 insertions, 0 deletions
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);
}