-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent templating being treated as attributes #1035
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reporting this issue and suggesting a fix!
I'd generally recommend that templating engines run first to avoid these types of syntax conflicts. However, in this case, I think it's a good idea to tighten our attribute syntax, which happens to have the nice benefit of fixing your templating issue 😉
Would you mind revising the regex and tweaking the test per my comments? Once done I'll cut a 2.5.1 release with the fix.
Both done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'll cut a new release with this fix shortly :)
Much appreciated! |
Hi @colinodell, Thanks a lot for this fix an more generaly for your impressive work on this library. As for this fix, I believe that it is maybe not enough in some cases where curly braces are employed within the text. For example, some {text in curly} brackets
some `{text in curly}` brackets will render as: <p text in curly>some brackets</p>
<p>some <code>{text in curly}</code> brackets</p> I am not sure of the right solution here:
Case 1- enabling the Attributes extension requires the Markdown author to change the way he writes content:
Here is a summary of the required changes in the way of writing markdown content: - A [Simple{Test}](https://example.com).
+ A [Simple\{Test}](https://example.com).
Another [Simple{{Test}}](https://example.com).
- some {text in} brackets
+ some \{text in} brackets
some `{text in}` brackets Case 2- Deprecate the support for empty-value attributesMaybe could we choose to deprecate the "empty value" attribute syntax and rather use an alternate syntax, for example:
I think this alternative syntax would be a good compromise:
However, the syntax proposed above ( In conclusion, I would either propose to prefix empty-value attributes with some text{~hello .test}
// translates to:
// <p hello class="test">some text</p> or: some text{hello=hello .test}
// translates to:
// <p hello="hello" class="test">some text</p> If you are interested, I can provide you with a pull request to enable this behavior :-) |
This PR prevents mustache-style template language strings being interpreted as attributes.
This was introduced in 2.5.0 by #986. It caused template strings to be wiped out.
This PR adds negative lookaheads to the regex to ignore the double-braces, allowing the template strings to be maintained:
I'm not sure if the changes to
AttributesHelperTest
are needed. They passed before making the regex change too.