I ran into an issue developing a recent site of a few zero width space characters (​) getting injecting into the html output:
Apparently Sublime Text 3 was the source of the problem, but these characters didn’t appear in the source. Opening the file in VIM allowed me to see the offending characters, this time <200b>
:
I could have simply deleted the code right there in VIM, but it scares me a little bit, so I wanted to be able to have these characters show in Sublime. Searching the web turned up an article on Stack Overflow to do just that.
Here’s how:
1. Create a new file and paste this code into it:
[python]
import sublime_plugin
class ShowZeroWidthSpace(sublime_plugin.EventListener):
def on_modified(self, view):
spaces = []
p = 0
while True:
s = view.find(u’\u200b’, p + 1)
if not s:
break
spaces.append(s)
p = s.a
if spaces:
view.add_regions("zero-width", spaces, "invalid")
else:
view.erase_regions("zero-width")
[/python]
2. Save this file to Packages/User
directory as show_zero_width_space.py
Here’s the full path to that directory: /Users/{user}/Library/Application Support/Sublime Text 3/Packages
Restart Sublime and you should be able to see the characters as lines, which are red for me:
Delete them and you should be good to go.
1 Comment
at