Fix bugs in misaka script.

This commit is contained in:
Frank Smit 2015-10-22 13:44:49 +02:00
parent 2a46ce9677
commit a56c96a2a4
1 changed files with 10 additions and 34 deletions

View File

@ -4,31 +4,7 @@ import sys
from os import path
from misaka import *
extensions = (
'tables',
'fenced-code',
'footnotes',
'autolink',
'strikethrough',
'underline',
'highlight',
'quote',
'superscript',
'math',
'no-intra-emphasis',
'space-headers',
'math-explicit',
'disable-indented-code',
)
html_flags = (
'skip-html',
'escape',
'hard-wrap',
'use-xhtml',
)
from misaka.utils import extension_map, html_flag_map
help = '''\
@ -44,8 +20,8 @@ Other options:
--smartypants
-h | --help
'''.format(
'\n'.join([' --ext-' + a for a in extensions]),
'\n'.join([' --html-' + a for a in html_flags]))
'\n'.join([' --ext-' + a for a in extension_map.keys()]),
'\n'.join([' --html-' + a for a in html_flag_map.keys()]))
if __name__ == '__main__':
@ -62,18 +38,18 @@ if __name__ == '__main__':
sys.exit(0)
elif arg == '--smartypants':
pants_enabled = True
elif arg.startswith('--ext'):
arg = arg[5:]
if not arg[5:] in extensions:
elif arg.startswith('--ext-'):
arg = arg[6:]
if not arg in extension_map:
print('--ext-{} is not a valid Markdown extension'.format(arg))
sys.exit(1)
extensions.append(arg)
elif arg.startswith('--html'):
arg = arg[6:]
if not arg[6:] in extensions:
elif arg.startswith('--html-'):
arg = arg[7:]
if not arg in html_flag_map:
print('--html-{} is not a valid HTML render flag'.format(arg))
sys.exit(1)
extensions.append(arg)
flags.append(arg)
else:
# If it's not a extension or HTML flag,
# then it must be a file, right?