Skip to content

Commit

Permalink
Allow 4+ spaces of indentation for image options
Browse files Browse the repository at this point in the history
Previously, this only supported 3.
  • Loading branch information
jelmer committed Sep 24, 2024
1 parent ebca18e commit 80b2b8f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parser/src/rst.pest
Original file line number Diff line number Diff line change
Expand Up @@ -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" }

Expand Down
25 changes: 25 additions & 0 deletions parser/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit 80b2b8f

Please sign in to comment.