def htmlify(txt):
- return txt.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("\xa0", ' ')
+ return re.sub(r'(\W)-', r'\1‑',
+ txt.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"')
+ .replace('--', '‑‑').replace("\xa0-", ' ‑').replace("\xa0", ' '))
def warn(*msg):
def main():
for mdfn in args.mdfiles:
+ if not mdfn.endswith('.md'):
+ print('Ignoring non-md input file:', mdfn)
+ continue
title = re.sub(r'.*/', '', mdfn).replace('.md', '')
htfn = mdfn.replace('.md', '.html')
html = md_parser(txt)
html = re.sub(r'(<code>)([\s\S]*?)(</code>)', lambda m: m[1] + re.sub(r'\s', '\xa0', m[2]) + m[3], html)
- html = html.replace("\xa0", ' ')
+ html = html.replace('--', '‑‑').replace("\xa0-", ' ‑').replace("\xa0", ' ')
+ html = re.sub(r'(\W)-', r'\1‑', html)
with open(htfn, 'w', encoding='utf-8') as fh:
fh.write(HTML_START % title)