fix: validate pandoc attribute content during parsing - #6567
costajohnt wants to merge 2 commits into
Conversation
The Pandoc attributes inline parser treated any {...} as a
PandocAttribute as long as it was preceded by whitespace and was the
last thing on the line, without checking whether the content inside
the braces was actually valid attribute syntax (#id, .class, key=val,
-, =format). A table cell (or paragraph) ending in a literal { ... }
that happened to satisfy the position check, e.g. "One of {Active,
Pending Approval, Removed}", had its braces and everything inside
them silently swallowed.
Add a content validator so the delimiter is only resolved into a
PandocAttribute when the content between the braces is empty or a
valid attribute list; otherwise the braces are left as literal text.
Fixes Zettlr#6563
|
Thank you for opening your first PR. We appreciate the time and effort you spent in creating this improvement. A maintainer will look at these changes shortly, and conduct a review. Please be patient, as everyone here works on this app in their free time. We will get to your PR as soon as we can.
If any of the above is unclear, or if you want to clarify something before jumping into action, please let us know; either with a comment here under your PR, or on the Community Forum or on Discord. We value upfront communication, since this can reduce misunderstandings and improve the efficiency of the work. |
|
Thank you for the PR! I will give this a more thorough review shortly, but one thing I noticed is that the pandoc attribute regex could probably be reused from https://github.com/Zettlr/Zettlr/blob/develop/source/common/pandoc-util/parse-pandoc-attributes.ts EDIT: Also, looking over the linked regex, it seems that two cases are not handled:
So these should be handled in the regex, and tests should be added to https://github.com/Zettlr/Zettlr/blob/develop/test/parse-pandoc-attributes.spec.ts |
Description
Braces at the end of a table cell disappeared in the editor because the parser read them as a pandoc attribute. This change makes it so we only treat braces as attributes when they actually look like them.
Changes
Added more strict check for attributes and a test.
Tested on
test on mac, ran testing suite.
Additional information
Closes #6563
AI Disclosure Statement
a coding agent found the cause, wrote the fix and tests, and ran them. i reviewed and tested the app myself.
Declarations
this PR. Usage of AI to generate code has been documented and made
transparent. I understand that AI cannot be an author and the commit messages
do not contain any chatbots or agents as "co-authors". There are no copyright
issues with my code.
not use an LLM to draft this description.
the additional information section.