Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions mkdocs_rss_plugin/templates/default.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ a:hover {
</p>
<div class="meta">

<xsl:if test="author">
By <xsl:value-of select="author"/>
<xsl:if test="managingEditor">
By <xsl:value-of select="managingEditor"/>
</xsl:if>

<xsl:if test="pubDate">
Expand Down Expand Up @@ -162,8 +162,8 @@ a:hover {
</h2>

<div class="meta">
<xsl:if test="author">
Par <xsl:value-of select="author"/>
<xsl:if test="dc:creator">
By <xsl:value-of select="dc:creator"/>
</xsl:if>
<xsl:if test="pubDate">
— <xsl:value-of select="pubDate"/>
Expand Down
4 changes: 2 additions & 2 deletions mkdocs_rss_plugin/templates/rss.xml.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
{% for item in feed.entries %}
<item>
<title>{{ item.title|e }}</title>
{# Authors loop #}
{# Authors loop - use dc:creator for names (RSS <author> requires email) #}
{% if item.authors is not none %}
{% for author in item.authors %}
<author>{{ author }}</author>
<dc:creator>{{ author|e }}</dc:creator>
{% endfor %}
{% endif %}
{# Categories loop #}
Expand Down
14 changes: 14 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import unittest
from pathlib import Path
from traceback import format_exception
from xml.etree import ElementTree

# 3rd party
import feedparser
Expand Down Expand Up @@ -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 <author> to be an email address,
# so human-readable names must use <dc:creator> 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(
Expand Down
Loading