mirror of
https://github.com/getpelican/pelican.git
synced 2026-06-03 22:46:55 +02:00
test: Strip ToC divs & backref anchors from summary
This commit is contained in:
parent
cdc88a5f1b
commit
1b96d38c20
1 changed files with 22 additions and 0 deletions
|
|
@ -172,6 +172,28 @@ class TestPage(TestBase):
|
|||
)
|
||||
self.assertIn("test_marker", page.summary)
|
||||
|
||||
def test_summary_strips_toc_elements(self):
|
||||
"""Auto-generated summary should strip TOC divs and toc-backref anchors."""
|
||||
page_kwargs = self._copy_page_kwargs()
|
||||
settings = get_settings()
|
||||
page_kwargs["settings"] = settings
|
||||
del page_kwargs["metadata"]["summary"]
|
||||
toc_content = (
|
||||
'<div class="contents topic" id="toc">'
|
||||
"<p>Table of contents</p>"
|
||||
'<ul><li><a href="#s1">Section</a></li></ul>'
|
||||
"</div>"
|
||||
'<h2><a class="toc-backref" href="#id1">My Section</a></h2>'
|
||||
"<p>First paragraph of real content.</p>"
|
||||
)
|
||||
page_kwargs["content"] = toc_content
|
||||
settings["SUMMARY_MAX_LENGTH"] = None
|
||||
page = Page(**page_kwargs)
|
||||
self.assertNotIn('<div class="contents', page.summary)
|
||||
self.assertNotIn("toc-backref", page.summary)
|
||||
self.assertIn("<h2>My Section</h2>", page.summary)
|
||||
self.assertIn("<p>First paragraph of real content.</p>", page.summary)
|
||||
|
||||
def test_summary_get_summary_warning(self):
|
||||
"""calling ._get_summary() should issue a warning"""
|
||||
page_kwargs = self._copy_page_kwargs()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue