mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Block attribute paragraph leaves leading newline in block (Pandoc spec violation) #756
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Asttear on GitHub (Sep 27, 2025).
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:
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:
\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:
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.