@@ -24,6 +24,13 @@ impl ConfigurationSection {
24
24
fn get_section < I : Iterator < Item = String > > (
25
25
file : & mut Enumerate < I > ,
26
26
) -> Option < ConfigurationSection > {
27
+ let config_name_regex = static_regex ! ( r"^## `([^`]+)`" ) ;
28
+ // Configuration values, which will be passed to `from_str`:
29
+ //
30
+ // - must be prefixed with `####`
31
+ // - must be wrapped in backticks
32
+ // - may by wrapped in double quotes (which will be stripped)
33
+ let config_value_regex = static_regex ! ( r#"^#### `"?([^`]+?)"?`"# ) ;
27
34
loop {
28
35
match file. next ( ) {
29
36
Some ( ( i, line) ) => {
@@ -40,15 +47,9 @@ impl ConfigurationSection {
40
47
let start_line = ( i + 2 ) as u32 ;
41
48
42
49
return Some ( ConfigurationSection :: CodeBlock ( ( block, start_line) ) ) ;
43
- } else if let Some ( c) = static_regex ! ( r"^## `([^`]+)`" ) . captures ( & line) {
50
+ } else if let Some ( c) = config_name_regex . captures ( & line) {
44
51
return Some ( ConfigurationSection :: ConfigName ( String :: from ( & c[ 1 ] ) ) ) ;
45
- } else if let Some ( c) = static_regex ! ( r#"^#### `"?([^`]+?)"?`"# ) . captures ( & line)
46
- {
47
- // Configuration values, which will be passed to `from_str`
48
- //
49
- // - must be prefixed with `####`
50
- // - must be wrapped in backticks
51
- // - may by wrapped in double quotes (which will be stripped)
52
+ } else if let Some ( c) = config_value_regex. captures ( & line) {
52
53
return Some ( ConfigurationSection :: ConfigValue ( String :: from ( & c[ 1 ] ) ) ) ;
53
54
}
54
55
}
0 commit comments