From 0e72d030addb30976089a98bbfaffdc0f10eacd7 Mon Sep 17 00:00:00 2001 From: ryanss Date: Sun, 11 Jan 2015 23:59:00 -0500 Subject: Add anchor tag parsing and syntax highlighting --- plugin/hackernews.py | 19 +++++++++++++++++-- syntax/hackernews.vim | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/plugin/hackernews.py b/plugin/hackernews.py index b924468..73470b7 100644 --- a/plugin/hackernews.py +++ b/plugin/hackernews.py @@ -43,7 +43,7 @@ def hacker_news_item(): b[0] = item['title'] b.append("Posted %s by %s" % (item['time_ago'], item['user'])) b.append("%d Points / %d Comments" % (item['points'], item['comments_count'])) - b.append(item['url']) + b.append("[%s]" % item['url']) b.append("") b.append("") print_comments(item['comments'], b) @@ -56,7 +56,22 @@ def print_comments(comments, b): level = comment['level'] b.append("%sComment by %s %s:" % ("\t"*level, comment.get('user','???'), comment['time_ago'])) for p in comment['content'].split("
"):
- contents = textwrap.wrap(html.unescape(re.sub('<[^<]+?>', '', p)),
+ p = html.unescape(p)
+ # Convert Text tags
+ # to markdown equivalent: (Text)[http://url/]
+ s = p.find("a>")
+ while s > 0:
+ s += 2
+ section = p[:s]
+ m = re.search(r"