summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorryanss2015-01-07 23:59:00 -0500
committerryanss2015-01-07 23:59:00 -0500
commit20be9d465429165b4b623c8fb34ccd62a9c10248 (patch)
tree34ee9473dcd77e39530d016f7c7157d3f6dc1359 /plugin
parent925b7ca10c0ce7d0636dc85ef5ff063b0f4a66a0 (diff)
downloadvim-hn-20be9d465429165b4b623c8fb34ccd62a9c10248.tar.gz
Unescape html entities in comments
Diffstat (limited to 'plugin')
-rw-r--r--plugin/hackernews.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/plugin/hackernews.py b/plugin/hackernews.py
index 6efd4eb..acbac04 100644
--- a/plugin/hackernews.py
+++ b/plugin/hackernews.py
@@ -1,3 +1,4 @@
+import HTMLParser
import json
import re
import textwrap
@@ -48,11 +49,13 @@ def hacker_news_item():
print_comments(item['comments'], b)
+html = HTMLParser.HTMLParser()
+
def print_comments(comments, b):
for comment in comments:
level = comment['level']
b.append("%sComment by %s %s:" % ("\t"*level, comment['user'], comment['time_ago']))
- contents = textwrap.wrap(re.sub('<[^<]+?>', '', comment['content']),
+ contents = textwrap.wrap(html.unescape(re.sub('<[^<]+?>', '', comment['content'])),
width=80,
initial_indent=" "*4*level,
subsequent_indent=" "*4*level)