Skip to content

Commit

Permalink
Handle Markup descriptions in Atom feeds
Browse files Browse the repository at this point in the history
The Atom feed generator did not account for text that was passed around
in a Markup object. Now it does, instead of triggering an assertion.

Fixes #7
  • Loading branch information
HenkKalkwater committed Jan 28, 2024
1 parent 5d1f9f5 commit 6768bbd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chumweb/atom_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from typing import List, Optional, Iterable
from xml.dom.minidom import Document, Element

from markupsafe import Markup

from chumweb import CONFIG
from chumweb.package import Package

Expand Down Expand Up @@ -138,7 +140,7 @@ def _create_pkg_entry(doc: Document, pkg: Package) -> Element:
return entry


def _create_simple_element(doc: Document, tag_name: str, content: Optional[str | Element | Iterable[Element]] = None,
def _create_simple_element(doc: Document, tag_name: str, content: Optional[str | Markup | Element | Iterable[Element]] = None,
ns: Optional[str] = None, **attrs) -> Element:
"""
Creates a XML tag with the given tag name, children and attributes
Expand All @@ -157,6 +159,8 @@ def _create_simple_element(doc: Document, tag_name: str, content: Optional[str |
pass
elif type(content) is str:
el.appendChild(doc.createTextNode(content))
elif type(content) is Markup:
el.appendChild(doc.createTextNode(content.unescape()))
elif type(content) is Element:
el.appendChild(content)
elif type(content) is Iterable[Element]:
Expand Down

0 comments on commit 6768bbd

Please sign in to comment.