Skip to content

Commit 80b2b8f

Browse files
committed
Allow 4+ spaces of indentation for image options
Previously, this only supported 3.
1 parent ebca18e commit 80b2b8f

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

parser/src/rst.pest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ replace = { ^"replace::" ~ " "* ~ paragraph }
8888

8989
image_directive = _{ ".." ~ PUSH(" "+) ~ image ~ DROP }
9090
image = { ^"image::" ~ line ~ image_opt_block? }
91-
image_opt_block = _{ PEEK[..-1] ~ PUSH(" " ~ POP) ~ image_option ~ (PEEK[..] ~ image_option)* }
91+
image_opt_block = _{ PEEK_ALL ~ PUSH(" "+ | "\t"+) ~ image_option ~ (PEEK_ALL ~ image_option)* }
9292
image_option = { ":" ~ image_opt_name ~ ":" ~ line }
9393
image_opt_name = { common_opt_name | "alt" | "height" | "width" | "scale" | "align" | "target" }
9494

parser/src/tests.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,31 @@ fn substitution_image_with_alt() {
423423
};
424424
}
425425

426+
#[allow(clippy::cognitive_complexity)]
427+
#[test]
428+
fn substitution_image_with_many_indents() {
429+
parses_to! {
430+
parser: RstParser,
431+
input: "\
432+
.. |subst| image:: thing.png
433+
:target: foo.html
434+
",
435+
rule: Rule::document,
436+
tokens: [
437+
substitution_def(0, 51, [
438+
substitution_name(4, 9),
439+
image(11, 51, [
440+
line(18, 29, [ str(18, 28) ]),
441+
image_option(33, 51, [
442+
image_opt_name(34, 40),
443+
line(41, 51, [ str(41, 50) ]),
444+
]),
445+
]),
446+
]),
447+
]
448+
};
449+
}
450+
426451
// TODO: test images
427452

428453
#[allow(clippy::cognitive_complexity)]

0 commit comments

Comments
 (0)