summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorryanss2015-02-10 14:26:01 -0500
committerryanss2015-02-10 14:26:01 -0500
commitb6f1f5b459c2c1c694a7271e99b2b47d0a74d0e4 (patch)
treeb3cc9e0947c4754cac96eb15e9c0bec3f48de047
parent553b8357657da1765186e255e1149ef5a9056bce (diff)
downloadvim-hn-b6f1f5b459c2c1c694a7271e99b2b47d0a74d0e4.tar.gz
Remove unwanted extra blank lines around code blocks
-rw-r--r--ftplugin/hackernews.py9
-rw-r--r--syntax/hackernews.vim2
2 files changed, 6 insertions, 5 deletions
diff --git a/ftplugin/hackernews.py b/ftplugin/hackernews.py
index ae294bb..2c7fd2a 100644
--- a/ftplugin/hackernews.py
+++ b/ftplugin/hackernews.py
@@ -35,7 +35,7 @@ def bwrite(s):
s = s.encode('utf-8', errors='replace')
# Code block markers for syntax highlighting
- if s and s[-1] == unichr(160).encode('utf-8'):
+ if s == unichr(160).encode('utf-8') and not b[-1]:
b[-1] = s
return
@@ -301,10 +301,11 @@ def print_comments(comments):
subsequent_indent=" "*4*level)
for line in contents:
if line.find("!CODE!") >= 0:
- bwrite(" "*4*level + unichr(160))
+ bwrite(unichr(160))
for c in code.split("\n"):
- bwrite(" "*4*level + c)
- bwrite(" "*4*level + unichr(160))
+ if c.strip():
+ bwrite(" "*4*level + c)
+ bwrite(unichr(160))
line = " "*4*level + line.replace("!CODE!", "").strip()
if line.strip():
bwrite(line)
diff --git a/syntax/hackernews.vim b/syntax/hackernews.vim
index acb7f72..d8b54ae 100644
--- a/syntax/hackernews.vim
+++ b/syntax/hackernews.vim
@@ -43,7 +43,7 @@ syn match Comment /^\s*Comment.*$/
syn region Constant start="\[http" end="\]"
" Highlight code blocks
-syn region Statement start="^\s\+ " end="^\s\+ "
+syn region Statement start="^ " end="^ "
" Highlight Hacker News header orange
syn match Title /^┌.*$/