mirror of
https://github.com/RsyncProject/rsync.git
synced 2026-03-10 10:27:13 -04:00
A few more md -> html improvements
This commit is contained in:
4
md2man
4
md2man
@@ -334,7 +334,9 @@ def manify(txt):
|
||||
|
||||
|
||||
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):
|
||||
|
||||
@@ -44,6 +44,9 @@ md_parser = None
|
||||
|
||||
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')
|
||||
|
||||
@@ -57,7 +60,8 @@ def main():
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user