From 03265efb46965f80cc62891c55c91a07142f29fb Mon Sep 17 00:00:00 2001 From: Justin Mayer Date: Tue, 25 Jun 2024 15:00:54 +0200 Subject: [PATCH] Fix-up --- docs/content.rst | 8 ++++---- docs/settings.rst | 2 +- pelican/tests/test_contents.py | 6 +++--- pelican/utils.py | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/content.rst b/docs/content.rst index 4a33a06e7..7d7e2cfae 100644 --- a/docs/content.rst +++ b/docs/content.rst @@ -162,10 +162,10 @@ author you can use ``author`` field. If you do not explicitly specify summary metadata for a given post, the ``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the -beginning of an article are used as the summary. You can also use the first N -paragraphs from the post as a summary using the ``SUMMARY_MAX_PARAGRAPHS`` -setting. If both options are in use, the specified number of paragraphs will -be used but may be truncated to respect the specified max length. +beginning of an article are used as the summary. You can also use an article's +first N paragraphs as its summary using the ``SUMMARY_MAX_PARAGRAPHS`` setting. +If both settings are in use, the specified number of paragraphs will +be used but may be truncated to respect the specified maximum length. You can also extract any metadata from the filename through a regular expression to be set in the ``FILENAME_METADATA`` setting. All named groups diff --git a/docs/settings.rst b/docs/settings.rst index 43da1140e..93c632d21 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -311,7 +311,7 @@ Basic settings .. data:: SUMMARY_MAX_PARAGRAPHS = None When creating a short summary of an article, this will be the number of - paragraphs to use as the summary. This only applies if your content + paragraphs to use as the summary. This only applies if your content does not otherwise specify a summary. Setting to ``None`` will cause the summary to use the whole text (up to ``SUMMARY_MAX_LENGTH``) instead of just the first N paragraphs. diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index 765a8df8c..06d1a6901 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -117,7 +117,7 @@ def test_summary_max_length(self): self.assertEqual(page.summary, "") def test_summary_paragraph(self): - # If a :SUMMARY_MAX_PARAGRAPHS: is set, the generated summary should + # If SUMMARY_MAX_PARAGRAPHS is set, the generated summary should # not exceed the given paragraph count. page_kwargs = self._copy_page_kwargs() settings = get_settings() @@ -129,8 +129,8 @@ def test_summary_paragraph(self): self.assertEqual(page.summary, TEST_CONTENT) def test_summary_paragraph_max_length(self): - # If a :SUMMARY_MAX_PARAGRAPHS: and :SUMMARY_MAX_LENGTH: are set, the - # generated summary should not exceed the given paragraph count and + # If both SUMMARY_MAX_PARAGRAPHS and SUMMARY_MAX_LENGTH are set, + # the generated summary should not exceed the given paragraph count and # not exceed the given length. page_kwargs = self._copy_page_kwargs() settings = get_settings() diff --git a/pelican/utils.py b/pelican/utils.py index 615454bd7..69d9dde51 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -632,7 +632,7 @@ def truncate_html_words(s: str, num: int, end_text: str = "…") -> str: def truncate_html_paragraphs(s, count): - """Truncates HTML to a certain number of paragraphs. + """Truncate HTML to a certain number of paragraphs. :param count: number of paragraphs to keep @@ -641,7 +641,7 @@ def truncate_html_paragraphs(s, count): paragraphs = [] tag_stop = 0 substr = s[:] - for i in range(count): + for _ in range(count): substr = substr[tag_stop:] tag_start = substr.find("

") tag_stop = substr.find("

") + len("

")