diff options
| author | Philipp A | 2018-11-15 22:31:53 +0100 | 
|---|---|---|
| committer | Philipp A | 2018-11-15 22:31:53 +0100 | 
| commit | 6316d8374655ff3debe33defc7697844fc8a7cb6 (patch) | |
| tree | daa578a226ba2b24c6f8ef51cb7909e0e9eb2728 | |
| parent | 2c04f8adcbe467e06fb5559dbcd125246f8ab49e (diff) | |
| download | rust-rst-6316d8374655ff3debe33defc7697844fc8a7cb6.tar.bz2 | |
fixed blank line handling
| -rw-r--r-- | src/parser/tests.rs | 31 | ||||
| -rw-r--r-- | src/rst.pest | 4 | 
2 files changed, 33 insertions, 2 deletions
| diff --git a/src/parser/tests.rs b/src/parser/tests.rs index 6b37b07..243cb26 100644 --- a/src/parser/tests.rs +++ b/src/parser/tests.rs @@ -73,7 +73,38 @@ fn two_targets() {              ]),          ]      }; +} + +#[test] +fn admonitions() { +    parses_to! { +        parser: RstParser, +        input: "\ +.. note:: In line +   Next line +.. admonition:: +   Just next line + +.. danger:: Just this line +", +        rule: Rule::document, +        tokens: [ +            admonition(0, 31, [ +                admonition_type(3, 7), +                line(9, 18), +                paragraph(21, 31, [ line(21, 31) ]), +            ]), +            admonition(31, 66, [ +                admonition_type(34, 44), +                paragraph(51, 66, [ line(51, 66) ]), +            ]), +            admonition(67, 94, [ +                admonition_type(70, 76), +                line(78, 94), +            ]), +        ] +    };  }  #[test] diff --git a/src/rst.pest b/src/rst.pest index 1c84d52..3d1d3d4 100644 --- a/src/rst.pest +++ b/src/rst.pest @@ -39,7 +39,7 @@ hanging_block = _{  // Note. A block type -admonition       =  { ".." ~ PUSH(" "+) ~ admonition_type ~ "::" ~ (blank_line | line) ~ admonition_body? ~ DROP } +admonition       =  { ".." ~ PUSH(" "+) ~ admonition_type ~ "::" ~ (blank_line | line) ~ blank_line* ~ admonition_body? ~ DROP }  admonition_type  =  { "attention" | "caution" | "danger" | "error" | "hint" | "important" | "note" | "tip" | "warning" | "admonition" }  admonition_body  = _{ PEEK[..-1] ~ PUSH("  " ~ POP) ~ hanging_block ~ block* } //TODO: merge with other directives? @@ -60,7 +60,7 @@ title = {  // Bullet list. A block type.  bullet_list =  { bullet_item ~ (PEEK[..] ~ bullet_item)* } -bullet_item =  { bullet_marker ~ PUSH(" "+) ~ line ~ blist_body? ~ DROP } +bullet_item =  { bullet_marker ~ PUSH(" "+) ~ line ~ blank_line* ~ blist_body? ~ DROP }  blist_body  = _{ PEEK[..-1] ~ PUSH(" " ~ POP) ~ hanging_block ~ block* } | 
