summaryrefslogtreecommitdiff
path: root/src/metadata.rs
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2020-12-21 08:38:46 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2020-12-21 08:39:31 +0000
commit24697edc6a661389b2d5e46dffdd76651b318a37 (patch)
tree0f4ac524faa01680101dd794a66f37d8b86282a6 /src/metadata.rs
parentbf748ff006c6a4c3f6853b1da7d090cebd825bd5 (diff)
downloadsubplot-24697edc6a661389b2d5e46dffdd76651b318a37.tar.gz
metadata: Support quoted strings
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src/metadata.rs')
-rw-r--r--src/metadata.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/metadata.rs b/src/metadata.rs
index 85c1576..69544c4 100644
--- a/src/metadata.rs
+++ b/src/metadata.rs
@@ -238,6 +238,15 @@ fn join_into_buffer(vec: &[Inline], buf: &mut String) {
pandoc_ast::Inline::Space => buf.push(' '),
pandoc_ast::Inline::SoftBreak => buf.push(' '),
pandoc_ast::Inline::LineBreak => buf.push(' '),
+ pandoc_ast::Inline::Quoted(qtype, v) => {
+ let quote = match qtype {
+ pandoc_ast::QuoteType::SingleQuote => '\'',
+ pandoc_ast::QuoteType::DoubleQuote => '"',
+ };
+ buf.push(quote);
+ join_into_buffer(v, buf);
+ buf.push(quote);
+ }
_ => panic!("unknown pandoc_ast::Inline component {:?}", item),
}
}
@@ -246,7 +255,7 @@ fn join_into_buffer(vec: &[Inline], buf: &mut String) {
#[cfg(test)]
mod test_join {
use super::join;
- use pandoc_ast::Inline;
+ use pandoc_ast::{Inline, QuoteType};
#[test]
fn join_all_kinds() {
@@ -260,9 +269,11 @@ mod test_join {
Inline::SmallCaps(vec![Inline::Str("g".to_string())]),
Inline::Space,
Inline::SoftBreak,
+ Inline::Quoted(QuoteType::SingleQuote, vec![Inline::Str("h".to_string())]),
Inline::LineBreak,
+ Inline::Quoted(QuoteType::DoubleQuote, vec![Inline::Str("i".to_string())]),
];
- assert_eq!(join(&v), "abcdefg ");
+ assert_eq!(join(&v), r#"abcdefg 'h' "i""#);
}
}