aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp A2018-11-23 10:31:18 +0100
committerPhilipp A2018-11-23 10:31:18 +0100
commit99c3bef8bb153e4b5eb189455f88458971f8ce54 (patch)
tree100e3a701eefd534722441e36927c211b9e64d3d
parentbc5af7498160a9072af5a731f5116ef2db1e30b9 (diff)
downloadrust-rst-99c3bef8bb153e4b5eb189455f88458971f8ce54.tar.bz2
fixed tests
-rw-r--r--src/parser/tests.rs25
-rw-r--r--src/rst.pest4
2 files changed, 14 insertions, 15 deletions
diff --git a/src/parser/tests.rs b/src/parser/tests.rs
index 40af5ac..74d741d 100644
--- a/src/parser/tests.rs
+++ b/src/parser/tests.rs
@@ -80,28 +80,27 @@ fn admonitions() {
parses_to! {
parser: RstParser,
input: "\
-.. note:: In line
- Next line
-.. admonition::
-
+.. note::
Just next line
+.. admonition:: In line title
+
+ Next line
.. danger:: Just this line
",
rule: Rule::document,
tokens: [
- admonition(0, 31, [
+ admonition_gen(0, 28, [
admonition_type(3, 7),
- line(9, 18),
- paragraph(21, 31, [ line(21, 31) ]),
+ paragraph(13, 28, [ line(13, 28) ]),
]),
- admonition(31, 66, [
- admonition_type(34, 44),
- paragraph(51, 66, [ line(51, 66) ]),
+ admonition(28, 72, [
+ line(43, 58),
+ paragraph(62, 72, [ line(62, 72) ]),
]),
- admonition(67, 94, [
- admonition_type(70, 76),
- line(78, 94),
+ admonition_gen(73, 100, [
+ admonition_type(76, 82),
+ line(84, 100),
]),
]
};
diff --git a/src/rst.pest b/src/rst.pest
index cd3baaf..b7888a4 100644
--- a/src/rst.pest
+++ b/src/rst.pest
@@ -5,7 +5,7 @@
// Section headers define the hierarchy by their delimiters,
// and pest only has one stack that we need for indentation.
-document = _{ SOI ~ blocks }
+document = _{ SOI ~ blocks ~ EOI }
blocks = _{ block ~ (blank_line* ~ block)* }
block = _{ PEEK[..] ~ hanging_block }
@@ -40,7 +40,7 @@ hanging_block = _{
// Admonition. A block type. The generic one has a title
-admonition = { ".." ~ PUSH(" "+) ~ "admonition::" ~ line ~ blank_line* ~ admonition_body? ~ DROP }
+admonition = { ".." ~ PUSH(" "+) ~ "admonition::" ~ !blank_line ~ line ~ blank_line* ~ admonition_body? ~ DROP }
admonition_gen = { ".." ~ PUSH(" "+) ~ admonition_type ~ "::" ~ (blank_line | line) ~ blank_line* ~ admonition_body? ~ DROP }
admonition_type = { "attention" | "caution" | "danger" | "error" | "hint" | "important" | "note" | "tip" | "warning" }
admonition_body = _{ PEEK[..-1] ~ PUSH(" " ~ POP) ~ hanging_block ~ block* } //TODO: merge with other directives?