Skip to content

Commit 38bb4ce

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

2 files changed

Lines changed: 27 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 = _{ PUSH(" "+) ~ image_option ~ (PEEK ~ image_option)* ~ DROP }
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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,32 @@ 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+
.. image:: thing.png
433+
:target: foo.html
434+
.. image:: another.png
435+
",
436+
rule: Rule::document,
437+
tokens: [
438+
image(3, 43, [
439+
line(10, 21, [ str(10, 20) ]),
440+
image_option(25, 43, [
441+
image_opt_name(26, 32),
442+
line(33, 43, [ str(33, 42) ]),
443+
]),
444+
]),
445+
image(46, 66, [
446+
line(53, 66, [ str(53, 65) ]),
447+
]),
448+
]
449+
};
450+
}
451+
426452
// TODO: test images
427453

428454
#[allow(clippy::cognitive_complexity)]

0 commit comments

Comments
 (0)