Skip to content

Definition list indented code block parsing inconsistencies #975

@ytmimi

Description

@ytmimi

As mentioned in this test case, an indented code block needs eight spaces of indentation however if the indented code block starts on the next line it's parsed after five spaces.

Running cargo run -- -e -D on the following input

bar
:       baz

produces these events:

0..16: Start(DefinitionList)
0..4: Start(DefinitionListTitle)
0..3: Text(Borrowed("bar"))
0..4: End(DefinitionListTitle)
4..16: Start(DefinitionListDefinition)
12..16: Start(CodeBlock(Indented))
12..16: Text(Borrowed("baz\n"))
12..16: End(CodeBlock)
4..16: End(DefinitionListDefinition)
0..16: End(DefinitionList)
EOF

And starting the code block on the next line only needs five spaces to parse an indented code block:

bar
:
     baz
0..15: Start(DefinitionList)
0..4: Start(DefinitionListTitle)
0..3: Text(Borrowed("bar"))
0..4: End(DefinitionListTitle)
4..15: Start(DefinitionListDefinition)
11..15: Start(CodeBlock(Indented))
11..15: Text(Borrowed("baz\n"))
11..15: End(CodeBlock)
4..15: End(DefinitionListDefinition)
0..15: End(DefinitionList)

Trying to start the code block using eight spaces of indentation on the next line results in extra whitespace being added to the indented code block.

bar
:
       baz
0..17: Start(DefinitionList)
0..4: Start(DefinitionListTitle)
0..3: Text(Borrowed("bar"))
0..4: End(DefinitionListTitle)
4..17: Start(DefinitionListDefinition)
11..17: Start(CodeBlock(Indented))
11..17: Text(Borrowed("  baz\n"))
11..17: End(CodeBlock)
4..17: End(DefinitionListDefinition)
0..17: End(DefinitionList)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions