@@ -24,9 +24,9 @@ pub enum RawChunk<'a> {
2424/// (and optionally source), and the `{l}` will be the license from
2525/// `Cargo.toml`.
2626///
27- /// Substitutions are alphabetic characters between curly braces, like `{p}`
28- /// or `{foo}` . The actual interpretation of these are done in the `Pattern`
29- /// struct.
27+ /// Substitutions are alphabetic characters or hyphens between curly braces,
28+ /// like `{p}`, { foo} or `{bar-baz}` . The actual interpretation of these is
29+ /// done in the `Pattern` struct.
3030///
3131/// Bare curly braces can be included in the output with double braces like
3232/// `{{` will include a single `{`, similar to Rust's format strings.
@@ -68,7 +68,7 @@ impl<'a> Parser<'a> {
6868
6969 loop {
7070 match self . it . peek ( ) {
71- Some ( & ( _, ch) ) if ch. is_alphanumeric ( ) => {
71+ Some ( & ( _, ch) ) if ch. is_alphanumeric ( ) || ch == '-' => {
7272 self . it . next ( ) ;
7373 }
7474 Some ( & ( end, _) ) => return & self . s [ start..end] ,
@@ -170,6 +170,12 @@ mod tests {
170170 ) ;
171171 }
172172
173+ #[ test]
174+ fn hyphenated_argument ( ) {
175+ let chunks: Vec < _ > = Parser :: new ( "{foo-bar}" ) . collect ( ) ;
176+ assert_eq ! ( chunks, vec![ RawChunk :: Argument ( "foo-bar" ) ] ) ;
177+ }
178+
173179 #[ test]
174180 fn unclosed_brace ( ) {
175181 let chunks: Vec < _ > = Parser :: new ( "{unclosed" ) . collect ( ) ;
@@ -197,7 +203,14 @@ mod tests {
197203 #[ test]
198204 fn invalid_argument_chars ( ) {
199205 let chunks: Vec < _ > = Parser :: new ( "{a-b} {123}" ) . collect ( ) ;
200- assert_eq ! ( chunks, vec![ RawChunk :: Error ( "expected '}'" ) ] ) ;
206+ assert_eq ! (
207+ chunks,
208+ vec![
209+ RawChunk :: Argument ( "a-b" ) ,
210+ RawChunk :: Text ( " " ) ,
211+ RawChunk :: Error ( "expected '}'" ) ,
212+ ]
213+ ) ;
201214 }
202215
203216 #[ test]
0 commit comments