Using a non-breaking zero-width char after a dash makes the browser
avoiding breaking on that dash and also makes it match a dash in a
search. This is better than a non-breaking dash char, which does not
match a dash in a search.
def htmlify(txt):
- return re.sub(r'(\W)-', r'\1‑',
+ return re.sub(r'(^|\W)-', r'\1-⁠',
txt.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"')
- .replace('--', '‑‑').replace("\xa0-", ' ‑').replace("\xa0", ' '))
+ .replace("\xa0", ' ').replace('--', '\4\4')).replace('\4', '-⁠')
def warn(*msg):