#!/usr/bin/env python
"""
jemdoc: light markup, see http://jemdoc.jaboc.net/.
version 0.3.4, November 2007.
"""
# Copyright (C) 2007 Jacob Mattingley.
#
# This file is part of jemdoc.
#
# jemdoc is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
#
# jemdoc is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see
| [menuend] |
[codeblockend]
| \n')
if g[6]:
out(f.outf, '' % g[6])
out(f.outf, ' | \n')
imgblock = True
else:
raise JandalError("couldn't handle block", linenum)
else:
s = br(np(f))
if s:
hb(f.outf, ' | \n', s) if footer: s = time.strftime('%Y-%m-%d %H:%M:%S %Z', time.localtime(time.time())) out(f.outf, f.conf['footerstart']) hb(f.outf, f.conf['lastupdated'], s) out(f.outf, f.conf['footerend']) if menu: out(f.outf, f.conf['menulastbit']) else: out(f.outf, f.conf['nomenulastbit']) out(f.outf, f.conf['bodyend']) if f.outf is not sys.stdout: f.outf.close() def main(): if len(sys.argv) == 1 or sys.argv[1] in ('--help', '-h'): showhelp() raise SystemExit if sys.argv[1] == '--show-config': print standardconf() raise SystemExit outoverride = False confoverride = False outname = None confnames = [] for i in range(1, len(sys.argv), 2): if sys.argv[i] == '-o': if outoverride: raise RuntimeError("only one output file / directory, please") outname = sys.argv[i+1] outoverride = True elif sys.argv[i] == '-c': if confoverride: raise RuntimeError("only one config file, please") confnames.append(sys.argv[i+1]) confoverride = True elif sys.argv[i].startswith('-'): raise RuntimeError('unrecognised argument %s, try --help' % sys.argv[i]) else: break conf = parseconf(confnames) innames = [] for j in range(i, len(sys.argv)): # First, if not a file and no dot, try opening .jemdoc. Otherwise, fall back # to just doing exactly as asked. inname = sys.argv[j] if not os.path.isfile(inname) and '.' not in inname: inname += '.jemdoc' innames.append(inname) if outname is not None and not os.path.isdir(outname) and len(innames) > 1: raise RuntimeError('cannot handle one outfile with multiple infiles') for inname in innames: if outname is None: thisout = re.sub(r'.jemdoc$', '', inname) + '.html' elif os.path.isdir(outname): # if directory, prepend directory to automatically generated name. thisout = outname + re.sub(r'.jemdoc$', '', inname) + '.html' else: thisout = outname infile = open(inname) outfile = open(thisout, 'w') f = controlstruct(infile, outfile, conf) procfile(f) # if __name__ == '__main__': main() |