diff --git a/cli/tests/input/unicode.xml b/cli/tests/input/unicode.xml new file mode 100644 index 000000000..9cdb11559 --- /dev/null +++ b/cli/tests/input/unicode.xml @@ -0,0 +1,49 @@ + + + + Put Your Internet Draft Title + + + Company + +
+ + + Springfield + IL + US + + + jdoe@example.com +
+
+ + + + + Insert an abstract: MANDATORY. This template is for creating an + Internet-Draft. With some out of scope characters + in Chinese, by Xing Xing, 这里是中文译本 + + +
+ + +
+ + Text body needs to deal with funny characters + + + Pure out of scope 这里是中文译本 + + + Some re-mapped characters are ¢ or © + + + More re-mapped characters are ˜ and € and ^ + +
+
+
diff --git a/cli/xml2rfc/utils.py b/cli/xml2rfc/utils.py index 555b1af04..46a35a753 100644 --- a/cli/xml2rfc/utils.py +++ b/cli/xml2rfc/utils.py @@ -307,7 +307,7 @@ def _replace_unicode_characters(str): if match.group(1) in _unicode_replacements: str = re.sub(match.group(1), _unicode_replacements[match.group(1)], str) else: - entity = match.group(1).encode('ascii', 'xmlcharrefreplace') + entity = match.group(1).encode('ascii', 'xmlcharrefreplace').decode('ascii') str = re.sub(match.group(1), entity, str) xml2rfc.log.warn('Illegal character replaced in string: ' + entity) diff --git a/cli/xml2rfc/writers/base.py b/cli/xml2rfc/writers/base.py index e220fb60f..50c1949d0 100644 --- a/cli/xml2rfc/writers/base.py +++ b/cli/xml2rfc/writers/base.py @@ -1022,6 +1022,13 @@ def _build_index(self): self.eref_count = 0 self.pis = self.xmlrfc.getpis() + # Abstract + abstract = self.r.find('front/abstract') + if abstract is not None: + self.write_heading('Abstract', autoAnchor='rfc.abstract') + for t in abstract.findall('t'): + self.write_t_rec(t) + # Middle sections middle = self.r.find('middle') if middle is not None: