Skip to content

Commit

Permalink
Merge pull request #118 from laws-africa/unicode
Browse files Browse the repository at this point in the history
support unicode chars
  • Loading branch information
longhotsummer authored Sep 1, 2023
2 parents ebe5e98 + da6a203 commit 2809b34
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bluebell/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.2.0"
__version__ = "2.3.0"
4 changes: 2 additions & 2 deletions bluebell/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def xml_from_dict(self, tree, is_root=False):
def xml_from_tree(self, tree):
""" Transform an entire parse tree to XML.
"""
return etree.fromstring(etree.tostring(self.item_to_xml(tree), encoding='unicode'))
return etree.fromstring(etree.tostring(self.item_to_xml(tree), encoding='utf-8'))

def item_to_xml(self, item):
return getattr(self, f'item_to_xml_{item["type"]}')(item)
Expand Down Expand Up @@ -510,7 +510,7 @@ def add_meta(self, xml):
if not self.frbr_uri:
raise ValueError("An frbr_uri must be provided when generating top-level documents.")

meta = etree.fromstring(etree.tostring(self.make_meta(self.frbr_uri, True)))
meta = etree.fromstring(etree.tostring(self.make_meta(self.frbr_uri, True), encoding='utf-8'))
list(xml)[0].insert(0, meta)
return xml

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ classifiers = [
"Programming Language :: Python :: 3",
]
dependencies = [
"cobalt>=7.0.0",
"cobalt>=8.0.0",
"lxml>=3.4.1",
]
dynamic = ["version"]
Expand Down
2 changes: 2 additions & 0 deletions tests/roundtrip/act.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CHAP 1 - Heading

SEC.custom-class{status edited} 1 - Section

emoji 😀

some **text** at //the start// with **multiple //types// of** markup

\***\*Notice**s\*\*
Expand Down
2 changes: 1 addition & 1 deletion tests/test_round_trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def roundtrip(self, prefix, root):
self.assertMultiLineEqual(input, actual)

# ensure it validates
doc = StructuredDocument.for_document_type(root)(etree.tostring(xml, encoding='unicode'))
doc = StructuredDocument.for_document_type(root)(etree.tostring(xml, encoding='utf-8'))
assert_validates(doc, strict=False)

def roundtrip_xml(self, file_in, root='statement'):
Expand Down

0 comments on commit 2809b34

Please sign in to comment.