diff options
author | Justin Mayer <entroP@gmail.com> | 2020-08-16 20:03:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-16 20:03:35 +0200 |
commit | 26a8909580364e93b0ec540cfe735e49a1a30082 (patch) | |
tree | 423d587b4b81373d28c7075435f4da9230bc0c27 /pelican | |
parent | 64bb392fefef1ad895626c6d4dc989fe73173766 (diff) | |
parent | 18b626aa8b43f513067d6c9ed00711e5e046ebca (diff) | |
download | pelican-26a8909580364e93b0ec540cfe735e49a1a30082.tar.gz |
Merge pull request #2785 from jwodder/lower-rst-summary
Lowercase metadata field name when comparing with FORMATTED_FIELDS in rST reader
Diffstat (limited to 'pelican')
-rw-r--r-- | pelican/readers.py | 2 | ||||
-rw-r--r-- | pelican/tests/content/article_with_capitalized_metadata.rst | 16 | ||||
-rw-r--r-- | pelican/tests/test_generators.py | 2 | ||||
-rw-r--r-- | pelican/tests/test_readers.py | 18 |
4 files changed, 37 insertions, 1 deletions
diff --git a/pelican/readers.py b/pelican/readers.py index 8c108510..15d09908 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -227,7 +227,7 @@ class RstReader(BaseReader): if element.tagname == 'field': # custom fields (e.g. summary) name_elem, body_elem = element.children name = name_elem.astext() - if name in formatted_fields: + if name.lower() in formatted_fields: value = render_node_to_html( document, body_elem, self.field_body_translator_class) diff --git a/pelican/tests/content/article_with_capitalized_metadata.rst b/pelican/tests/content/article_with_capitalized_metadata.rst new file mode 100644 index 00000000..93ed5b15 --- /dev/null +++ b/pelican/tests/content/article_with_capitalized_metadata.rst @@ -0,0 +1,16 @@ + +This is a super article ! +######################### + +:TAGS: foo, bar, foobar +:DATE: 2010-12-02 10:14 +:MODIFIED: 2010-12-02 10:20 +:CATEGORY: yeah +:AUTHOR: Alexis Métaireau +:SUMMARY: + Multi-line metadata should be supported + as well as **inline markup** and stuff to "typogrify"... +:CUSTOM_FIELD: http://notmyidea.org +:CUSTOM_FORMATTED_FIELD: + Multi-line metadata should also be supported + as well as *inline markup* and stuff to "typogrify"... diff --git a/pelican/tests/test_generators.py b/pelican/tests/test_generators.py index 332d7e78..169765ac 100644 --- a/pelican/tests/test_generators.py +++ b/pelican/tests/test_generators.py @@ -260,6 +260,7 @@ class TestArticlesGenerator(unittest.TestCase): ['This is a super article !', 'published', 'yeah', 'article'], ['This is a super article !', 'published', 'yeah', 'article'], ['This is a super article !', 'published', 'yeah', 'article'], + ['This is a super article !', 'published', 'yeah', 'article'], ['This is a super article !', 'published', 'Default', 'article'], ['Article with an inline SVG', 'published', 'Default', 'article'], ['This is an article with category !', 'published', 'yeah', @@ -576,6 +577,7 @@ class TestArticlesGenerator(unittest.TestCase): 'This is a super article !', 'This is a super article !', 'This is a super article !', + 'This is a super article !', 'This is an article with category !', ('This is an article with multiple authors in lastname, ' 'firstname format!'), diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py index de2a1b22..ea5f3bdd 100644 --- a/pelican/tests/test_readers.py +++ b/pelican/tests/test_readers.py @@ -155,6 +155,24 @@ class RstReaderTest(ReaderTest): self.assertDictHasSubset(page.metadata, expected) + def test_article_with_capitalized_metadata(self): + page = self.read_file(path='article_with_capitalized_metadata.rst') + expected = { + 'category': 'yeah', + 'author': 'Alexis Métaireau', + 'title': 'This is a super article !', + 'summary': '<p class="first last">Multi-line metadata should be' + ' supported\nas well as <strong>inline' + ' markup</strong> and stuff to "typogrify' + '"...</p>\n', + 'date': SafeDatetime(2010, 12, 2, 10, 14), + 'modified': SafeDatetime(2010, 12, 2, 10, 20), + 'tags': ['foo', 'bar', 'foobar'], + 'custom_field': 'http://notmyidea.org', + } + + self.assertDictHasSubset(page.metadata, expected) + def test_article_with_filename_metadata(self): page = self.read_file( path='2012-11-29_rst_w_filename_meta#foo-bar.rst', |