Skip to content

Commit 421f1e8

Browse files
authored
Give smarty tree processor higher priority than toc
And add a test for using smarty in ToC headers. Fixes #1438.
1 parent c334a3e commit 421f1e8

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Diff for: docs/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

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

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

Diff for: markdown/extensions/smarty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def extendMarkdown(self, md):
269269
self.educateDashes(md)
270270
inlineProcessor = InlineProcessor(md)
271271
inlineProcessor.inlinePatterns = self.inlinePatterns
272-
md.treeprocessors.register(inlineProcessor, 'smarty', 2)
272+
md.treeprocessors.register(inlineProcessor, 'smarty', 6)
273273
md.ESCAPED_CHARS.extend(['"', "'"])
274274

275275

Diff for: tests/test_syntax/extensions/test_smarty.py

+23
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,26 @@ def test_custom_substitutions(self):
198198
'Must not be confused with &sbquo;ndash&lsquo; (\u2013) \u2026 ]</p>'
199199
)
200200
self.assertMarkdownRenders(text, html)
201+
202+
203+
class TestSmartyAndToc(TestCase):
204+
205+
default_kwargs = {
206+
'extensions': ['smarty', 'toc'],
207+
}
208+
209+
def test_smarty_and_toc(self):
210+
self.assertMarkdownRenders(
211+
'# *Foo* --- `bar`',
212+
'<h1 id="foo-bar"><em>Foo</em> &mdash; <code>bar</code></h1>',
213+
expected_attrs={
214+
'toc_tokens': [
215+
{
216+
'level': 1,
217+
'id': 'foo-bar',
218+
'name': 'Foo &mdash; bar',
219+
'children': [],
220+
},
221+
],
222+
},
223+
)

0 commit comments

Comments
 (0)