Allow names with multiple hyphens in a row

Fixes 
This commit is contained in:
Chris Wong 2016-08-07 20:39:31 +12:00
parent 1ec48a3725
commit d2bf70da9a
2 changed files with 22 additions and 4 deletions
maud_macros

View file

@ -557,10 +557,21 @@ impl<'cx, 'a, 'i> Parser<'cx, 'a, 'i> {
}, },
_ => return Err(FatalError), _ => return Err(FatalError),
}; };
while let [minus!(), ident!(_, name), ..] = *self.input { let mut expect_ident = false;
self.shift(2); loop {
s.push('-'); expect_ident = match *self.input {
s.push_str(&name.name.as_str()); [minus!(), ..] => {
self.shift(1);
s.push('-');
true
},
[ident!(_, name), ..] if expect_ident => {
self.shift(1);
s.push_str(&name.name.as_str());
false
},
_ => break,
};
} }
Ok(s) Ok(s)
} }

View file

@ -130,6 +130,13 @@ fn classes_shorthand() {
assert_eq!(s, r#"<p>Hi, <span class="name here">Lyra</span>!</p>"#); assert_eq!(s, r#"<p>Hi, <span class="name here">Lyra</span>!</p>"#);
} }
#[test]
fn hyphens_in_class_names() {
let mut s = String::new();
html!(s, p.rocks-these.are--my--rocks "yes").unwrap();
assert_eq!(s, r#"<p class="rocks-these are--my--rocks">yes</p>"#);
}
#[test] #[test]
fn ids_shorthand() { fn ids_shorthand() {
let mut s = String::new(); let mut s = String::new();