Skip to content
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

abbr extension breaks title attribute added using attr_list #1460

Closed
nbanyan opened this issue Apr 23, 2024 · 1 comment · Fixed by #1461
Closed

abbr extension breaks title attribute added using attr_list #1460

nbanyan opened this issue Apr 23, 2024 · 1 comment · Fixed by #1461
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. extension Related to one or more of the included extensions.

Comments

@nbanyan
Copy link
Contributor

nbanyan commented Apr 23, 2024

Bug description

*[abbr]: Abbreviation Definition

![Image with abbr in title](abbr.png){title="Image with abbr in title"}

This renders the attribute code as plain text because the Abbreviation extension modifies the text in the attribute causing it to no longer be a valid attribute list.

Reproduction

9.5.18-abbr-attr_list-conflict.zip

Steps to reproduce

  1. Enable the abbr and attr_list extensions
  2. Include an abbreviation definition on a page
  3. Use the abbreviation in a title attribute for an object using the attr_list syntax
@waylan
Copy link
Member

waylan commented Apr 23, 2024

I can confirm this is an issue.

>>> import markdown
>>> src = '''
... *[abbr]: Abbreviation Definition
...
... ![Image with abbr in title](abbr.png){title="Image with abbr in title"}
... '''
>>> markdown.markdown(src, extensions=['abbr', 'attr_list'])
'<p><img alt="Image with abbr in title" src="abbr.png" />{title="Image with <abbr title="Abbreviation Definition">abbr</abbr> in title"}</p>'

The cause of the issue is that the abbr extension runs an inline processor while the attr_list extension runs a treeprocessor. If both extensions used the same type of processor we would just ensure they were ordered so that the attr_list processor ran first. But being different processor types, it is not so easy. Especially because we generally want inline processors to run before attr_list so that attribute lists can be applied to inline elements.

This may require use of a custom treeprocessor for the addr extension which runs later. I will have to think about that.

@waylan waylan added bug Bug report. extension Related to one or more of the included extensions. confirmed Confirmed bug report or approved feature request. labels Apr 23, 2024
waylan added a commit to waylan/markdown that referenced this issue Apr 24, 2024
A new `AbbrTreeprocessor` has been introduced, which replaces the now
deprecated `AbbrInlineProcessor`. Abbreviation processing now happens
after Attribute Lists, avoiding a conflict between the two extensions.
Fixes Python-Markdown#1460.
waylan added a commit that referenced this issue Apr 25, 2024
A new `AbbrTreeprocessor` has been introduced, which replaces the now
deprecated `AbbrInlineProcessor`. Abbreviation processing now happens
after Attribute Lists, avoiding a conflict between the two extensions.
Fixes #1460.

The `AbbrPreprocessor` class has been renamed to `AbbrBlockprocessor`, which
better reflects what it is. `AbbrPreprocessor` has been deprecated.

A call to `Markdown.reset()` now clears all previously defined abbreviations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report. confirmed Confirmed bug report or approved feature request. extension Related to one or more of the included extensions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants