Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Include `scripts/*.py` in the generated source tarballs (#1430).
* Ensure lines after heading in loose list are properly detabbed (#1443).
* Give smarty tree processor higher priority than toc (#1440).

## [3.5.2] -- 2024-01-10

Expand Down
2 changes: 1 addition & 1 deletion markdown/extensions/smarty.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def extendMarkdown(self, md):
self.educateDashes(md)
inlineProcessor = InlineProcessor(md)
inlineProcessor.inlinePatterns = self.inlinePatterns
md.treeprocessors.register(inlineProcessor, 'smarty', 2)
md.treeprocessors.register(inlineProcessor, 'smarty', 6)
md.ESCAPED_CHARS.extend(['"', "'"])


Expand Down
23 changes: 23 additions & 0 deletions tests/test_syntax/extensions/test_smarty.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,26 @@ def test_custom_substitutions(self):
'Must not be confused with &sbquo;ndash&lsquo; (\u2013) \u2026 ]</p>'
)
self.assertMarkdownRenders(text, html)


class TestSmartyAndToc(TestCase):

default_kwargs = {
'extensions': ['smarty', 'toc'],
}

def test_smarty_and_toc(self):
self.assertMarkdownRenders(
'# *Foo* --- `bar`',
'<h1 id="foo-bar"><em>Foo</em> &mdash; <code>bar</code></h1>',
expected_attrs={
'toc_tokens': [
{
'level': 1,
'id': 'foo-bar',
'name': 'Foo &mdash; bar',
'children': [],
},
],
},
)