diff --git a/mkdocs_rss_plugin/templates/default.xsl b/mkdocs_rss_plugin/templates/default.xsl index 3a11d00..5f989c0 100644 --- a/mkdocs_rss_plugin/templates/default.xsl +++ b/mkdocs_rss_plugin/templates/default.xsl @@ -131,8 +131,8 @@ a:hover {

- - By + + By @@ -162,8 +162,8 @@ a:hover {
- - Par + + By — diff --git a/mkdocs_rss_plugin/templates/rss.xml.jinja2 b/mkdocs_rss_plugin/templates/rss.xml.jinja2 index 5328672..a81c50b 100644 --- a/mkdocs_rss_plugin/templates/rss.xml.jinja2 +++ b/mkdocs_rss_plugin/templates/rss.xml.jinja2 @@ -34,10 +34,10 @@ {% for item in feed.entries %} {{ item.title|e }} - {# Authors loop #} + {# Authors loop - use dc:creator for names (RSS requires email) #} {% if item.authors is not none %} {% for author in item.authors %} - {{ author }} + {{ author|e }} {% endfor %} {% endif %} {# Categories loop #} diff --git a/tests/test_build.py b/tests/test_build.py index 8b18057..2a1d088 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -20,6 +20,7 @@ import unittest from pathlib import Path from traceback import format_exception +from xml.etree import ElementTree # 3rd party import feedparser @@ -172,6 +173,19 @@ def test_simple_build_complete(self): "Page with complete meta", {e.title for e in feed_parsed.entries} ) + # authors: RSS 2.0 requires to be an email address, + # so human-readable names must use instead + tree = ElementTree.parse(Path(tmpdirname) / OUTPUT_RSS_FEED_CREATED) + dc_namespace = "http://purl.org/dc/elements/1.1/" + for item in tree.getroot().findall(".//item"): + self.assertIsNone(item.find("author")) + if item.find("title").text == "Page with complete meta": + creators = item.findall(f"{{{dc_namespace}}}creator") + self.assertEqual( + [c.text for c in creators], + ["Guts", "Tim Vink", "liang2kl"], + ) + def test_simple_build_disabled(self): with tempfile.TemporaryDirectory() as tmpdirname: cli_result = self.build_docs_setup(