| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Ancestors used to continually add duplicate parents that were already present. Call `__build_ancestors` once at the beginning and then manage ancestors as appropriate.
|
To clarify the motivation for this change. The ancestor handling used to duplicate parents that were already added. This could cause real performance issues for certain patterns: Before, parent tags would get duplicated. Notice div and p constantly being duplicated. >>> import markdown
>>> text = '**_test_* ******test*******'
>>> markdown.markdown(text, extensions=['pymdownx.betterem'])
['div']
['div', 'p', 'div', 'p', 'em']
['div', 'p', 'div', 'p', 'em', 'div', 'p', 'em', 'em']
['div', 'p', 'div', 'p', 'em', 'div', 'p', 'em', 'strong']
['div', 'p', 'div', 'p', 'em', 'div', 'p', 'em', 'strong', 'div', 'p', 'em', 'strong', 'strong']
'<p><em><em><em>test</em></em> <strong><strong><strong>test</strong></strong></strong></em></p>'Now, they get handled more reasonably: ➜ markdown_fork git:(fix-ancestors) ✗ python3
Python 3.14.7 (v3.14.7:823f0323ee6, Aug 5 2026, 07:07:01) [Clang 21.0.0 (clang-2100.1.1.101)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import markdown
>>> text = '**_test_* ******test*******'
>>> markdown.markdown(text, extensions=['pymdownx.betterem'])
['div']
['div', 'p', 'em']
['div', 'p', 'em', 'em']
['div', 'p', 'em', 'strong']
['div', 'p', 'em', 'strong', 'strong']
'<p><em><em><em>test</em></em> <strong><strong><strong>test</strong></strong></strong></em></p>'This reduces performance degradation for certain patterns. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Ancestors used to continually add duplicate parents that were already present.
Call __build_ancestors once at the beginning and then manage ancestors as appropriate.
Description
AI Assistance Disclosure
Checklist