Add class to hard tabs and leading/trailing spaces

This allows whitespace to be still be styled when invisibles
are disabled.
This commit is contained in:
Kevin Sawicki
2013-02-12 13:25:20 -08:00
parent 9af54de0f6
commit 5f84ec711b
2 changed files with 32 additions and 1 deletions

View File

@@ -80,5 +80,16 @@ class Token
if hasTrailingWhitespace
html = html.replace /[ ]+$/, (match) ->
"<span class='invisible trailing-whitespace'>#{match.replace(/./g, invisibles.space)}</span>"
else
if @isHardTab
html = html.replace /^./, (match) ->
"<span class='hard-tab'>#{match}</span>"
else
if hasLeadingWhitespace
html = html.replace /^[ ]+/, (match) ->
"<span class='leading-whitespace'>#{match}</span>"
if hasTrailingWhitespace
html = html.replace /[ ]+$/, (match) ->
"<span class='trailing-whitespace'>#{match}</span>"
html