Skip to content

Only treat a line as attributes when nothing follows - #4

Open
pgundlach wants to merge 1 commit into
mdigger:masterfrom
pgundlach:attribute-line-must-be-alone
Open

pgundlach wants to merge 1 commit into
mdigger:masterfrom
pgundlach:attribute-line-must-be-alone

Conversation

@pgundlach

Copy link
Copy Markdown

Fixes #3.

A line that starts with a valid attribute list but continues with other text ({.class} trailing text) was consumed as an attributes block and the trailing text was silently dropped from the output.

This change requires the attribute list to be the only content on its line: after parser.ParseAttributes succeeds, Open now checks that the rest of the line is blank. Otherwise it restores the saved reader position (the same pattern ParseAttributes itself uses on failure) and returns parser.RequireParagraph, so the line stays regular paragraph text.

The new test covers the three cases: a pure attribute line still attaches, a trailing-text line stays literal text inside the paragraph, and a standalone { .foo } some text line no longer vanishes. The existing tests pass unchanged.

A line that starts with a valid attribute list but continues with
other text ("{.class} trailing text") was consumed as an attributes
block and the trailing text was silently dropped from the output.
Such a line is regular paragraph text: require the rest of the line
to be blank, otherwise restore the reader position and fall through
to the paragraph parser.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text after an attribute line is silently dropped

1 participant