-
-
Notifications
You must be signed in to change notification settings - Fork 497
Description
Bug Description
When using GenericAttributesParser, if an attribute block (e.g., {.center}) appears on a line by itself immediately before a block element (such as a paragraph), the resulting block element includes a leading newline (\n) in its content.
Expected Behavior
According to the Pandoc Markdown specification:
Attributes that occur immediately before a block element, on a line by themselves, affect that element.
The attribute block should be associated with the following block element, but the content of the block element should not include an extra leading newline.
How to Reproduce
Steps:
- Create a markdown file containing:
{.center} A paragraph - Parse this with Markdig (with GenericAttributes enabled)
- Observe that the paragraph block contains a leading
\nin its content.
Actual Behavior
The paragraph block has a leading newline before the text, which is preserved in the rendered HTML or output.
Expected Output
The paragraph should have the attribute applied, but its content should be:
A paragraph
without any leading newline.
Reference
Pandoc Markdown spec: https://pandoc.org/MANUAL.html#extension-attributes
Additional Context
This may be due to how the parser transitions from the attribute block to the following block, and does not trim the whitespace. This leads to non-compliance with Markdown attribute extension behavior as described in Pandoc.
Please consider aligning this behavior with the Pandoc spec by trimming/removing the leading newline when attaching attributes from an attribute-only paragraph to the next block.