summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2021-09-18 10:46:33 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2021-09-18 10:46:33 +0100
commitd47a844e13f48ae82a79f2d3434098cdabe83e12 (patch)
treed899b46ddedaf90327d9e75f314aaf81bdc467af
parent59311238193b0b0b4cdd7d0e90db6c1804a19521 (diff)
downloadsubplot-d47a844e13f48ae82a79f2d3434098cdabe83e12.tar.gz
ast: codeblocks with single words are classes not IDs
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
-rw-r--r--src/ast.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/ast.rs b/src/ast.rs
index 2033553..9543efd 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -228,8 +228,8 @@ fn parse_code_block_attrs(attrs: &str) -> Attr {
keyvalues.push((k.to_string(), v.to_string()));
}
}
- } else {
- id = attrs.to_string();
+ } else if !attrs.is_empty() {
+ classes.push(attrs.to_string());
}
(id, classes, keyvalues)
}
@@ -355,9 +355,10 @@ mod test {
#[test]
fn code_block_attrs() {
+ assert_eq!(parse_code_block_attrs(""), ("".to_string(), vec![], vec![]));
assert_eq!(
parse_code_block_attrs("foo"),
- ("foo".to_string(), vec![], vec![])
+ ("".to_string(), vec!["foo".to_string()], vec![])
);
assert_eq!(
parse_code_block_attrs("{#foo}"),