-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many HTML entities don't work #43
Comments
Same is true for greek letters and math symbols |
The problem seems to be, that the entity translator dict The following monkey patch works for me: import kajiki
kajiki.entities.html5.update(
{k[:-1]: v
for k, v in kajiki.entities.html5.items()
if k[-1]==';' and k[:-1] not in kajiki.entities.html5
})
from kajiki import XMLTemplate
t = XMLTemplate('<xml>…</xml>')
print(t().render()) If this fast fix is ok for now, I can provide a PR, of course. |
should provide a reasonable solution to the problem without having to maintain our own delta from https://github.com/python/cpython/blob/master/Lib/html/entities.py#L264 |
Thank you for the fast solution, for now I am going with this, do you think the version estimate to get it fixed in a PyPI release ok? if kajiki.__version__ < '0.9':
kajiki.entities.html5.update(
{k[:-1]: v
for k, v in kajiki.entities.html5.items()
if k[-1] == ';' and k[:-1] not in kajiki.entities.html5
}) |
Released 0.8.2 https://pypi.org/project/Kajiki/0.8.2/ |
Many HTML entities i.e. … cause KeyError:
Try:
kajiki.XMLTemplate(u'<div>© …</div>')
Result:
Traceback (most recent call last): File "<input>", line 1, in <module> Template = kajiki.XMLTemplate(u'<div>© …</div>') File "/usr/lib/python2.7/dist-packages/kajiki/xml_template.py", line 52, in XMLTemplate doc = _Parser(filename, source).parse() File "/usr/lib/python2.7/dist-packages/kajiki/xml_template.py", line 629, in parse parser.parse(source) File "/usr/lib/python2.7/xml/sax/expatreader.py", line 110, in parse xmlreader.IncrementalParser.parse(self, source) File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse self.feed(buffer) File "/usr/lib/python2.7/xml/sax/expatreader.py", line 213, in feed self._parser.Parse(data, isFinal) File "/usr/lib/python2.7/xml/sax/expatreader.py", line 416, in skipped_entity_handler self._cont_handler.skippedEntity(name) File "/usr/lib/python2.7/dist-packages/kajiki/xml_template.py", line 675, in skippedEntity return self.characters(html5[name]) KeyError: u'hellip'
The text was updated successfully, but these errors were encountered: