diff --git a/parser/src/rst.pest b/parser/src/rst.pest index 7c45153..c7bb281 100644 --- a/parser/src/rst.pest +++ b/parser/src/rst.pest @@ -88,7 +88,7 @@ replace = { ^"replace::" ~ " "* ~ paragraph } image_directive = _{ ".." ~ PUSH(" "+) ~ image ~ DROP } image = { ^"image::" ~ line ~ image_opt_block? } -image_opt_block = _{ PEEK[..-1] ~ PUSH(" " ~ POP) ~ image_option ~ (PEEK[..] ~ image_option)* } +image_opt_block = _{ PEEK_ALL ~ PUSH(" "+ | "\t"+) ~ image_option ~ (PEEK_ALL ~ image_option)* } image_option = { ":" ~ image_opt_name ~ ":" ~ line } image_opt_name = { common_opt_name | "alt" | "height" | "width" | "scale" | "align" | "target" } diff --git a/parser/src/tests.rs b/parser/src/tests.rs index fdacf8c..0ec3eda 100644 --- a/parser/src/tests.rs +++ b/parser/src/tests.rs @@ -423,6 +423,31 @@ fn substitution_image_with_alt() { }; } +#[allow(clippy::cognitive_complexity)] +#[test] +fn substitution_image_with_many_indents() { + parses_to! { + parser: RstParser, + input: "\ +.. |subst| image:: thing.png + :target: foo.html +", + rule: Rule::document, + tokens: [ + substitution_def(0, 51, [ + substitution_name(4, 9), + image(11, 51, [ + line(18, 29, [ str(18, 28) ]), + image_option(33, 51, [ + image_opt_name(34, 40), + line(41, 51, [ str(41, 50) ]), + ]), + ]), + ]), + ] + }; +} + // TODO: test images #[allow(clippy::cognitive_complexity)]