144 |
145 | [footerstart]
146 |
152 |
153 | [lastupdated]
154 | Last updated |, using jemdoc.
155 | """
156 |
157 | class JandalError(Exception):
158 | pass
159 |
160 | def raisejandal(msg, line=0):
161 | if line == 0:
162 | s = "%s" % msg
163 | else:
164 | s = "line %d: %s" % (line, msg)
165 | raise JandalError(s)
166 |
167 | if len(sys.argv) == 1 or sys.argv[1] in ('--help', '-h'):
168 | showhelp()
169 | raise SystemExit
170 | elif len(sys.argv[2:]) % 2 != 0:
171 | raise JandalError('invalid arguments, try --help')
172 | if sys.argv[1] == '--show-config':
173 | print standardconf()
174 | raise SystemExit
175 | else:
176 | inname = sys.argv[-1]
177 | outname = re.search(r'(.*)\.', inname).group(1) + '.html'
178 |
179 | outoverride = False
180 | confoverride = False
181 | confnames = []
182 | for i in range(1, len(sys.argv) - 1, 2):
183 | if sys.argv[i] == '-o':
184 | if outoverride:
185 | raise RuntimeError("only one output file, please")
186 | outname = sys.argv[i+1]
187 | outoverride = True
188 | elif sys.argv[i] == '-c':
189 | if confoverride:
190 | raise RuntimeError("only one config file, please")
191 | confnames.append(sys.argv[i+1])
192 | confoverride = True
193 | else:
194 | raise RuntimeError('unrecognised argument %s, try --help' % sys.argv[i])
195 |
196 | def readnoncomment(f):
197 | l = f.readline()
198 | if l == '':
199 | return l
200 | elif l[0] == '#': # jem: be a little more generous with the comments we accept?
201 | return readnoncomment(f)
202 | else:
203 | return l.rstrip() + '\n' # leave just one \n and no spaces etc.
204 |
205 | def parseconf(cns):
206 | syntax = {}
207 | warn = False # jem. make configurable?
208 | # manually add the defaults as a file handle.
209 | fs = [StringIO.StringIO(standardconf())]
210 | for sname in cns:
211 | fs.append(open(sname))
212 |
213 | for f in fs:
214 | while pc(f) != '':
215 | l = readnoncomment(f)
216 | r = re.match(r'\[(.*)\]\n', l)
217 |
218 | if r:
219 | tag = r.group(1)
220 |
221 | s = ''
222 | l = readnoncomment(f)
223 | while l not in ('\n', ''):
224 | s += l
225 | l = readnoncomment(f)
226 |
227 | syntax[tag] = s
228 |
229 | f.close()
230 |
231 | return syntax
232 |
233 | def insertmenuitems(mname, current):
234 | f = open(mname)
235 | while pc(f) != '':
236 | l = readnoncomment(f)
237 | l = l.strip()
238 | if l == '':
239 | continue
240 |
241 | r = re.match(r'\s*(.*?)\s*\[(.*)\]', l)
242 |
243 | if r: # then we have a link.
244 | if r.group(2) == current:
245 | hb(conf['currentmenuitem'], r.group(2), br(r.group(1)))
246 | else:
247 | hb(conf['menuitem'], r.group(2), br(r.group(1)))
248 |
249 | else: # menu category.
250 | hb(conf['menucategory'], br(l))
251 |
252 | f.close()
253 |
254 |
255 | infile = open(inname)
256 | outfile = open(outname, 'w')
257 |
258 | def out(s):
259 | outfile.write(s)
260 |
261 | def hb(tag, content1, content2=None):
262 | """Writes out a halfblock (hb)."""
263 | if content2 is None:
264 | out(re.sub(r'\|', content1, tag))
265 | else:
266 | r = re.sub(r'\|1', content1, tag)
267 | r = re.sub(r'\|2', content2, r)
268 | out(r)
269 |
270 | def pc(f = infile):
271 | """Peeks at next character in the file."""
272 | # Should only be used to look at the first character of a new line.
273 | c = f.read(1)
274 | if c: # only undo forward movement if we're not at the end.
275 | #if c == '#': # interpret comment lines as blank.
276 | # return '\n'
277 |
278 | if c in ' \t':
279 | return pc()
280 |
281 | f.seek(-1, 1)
282 |
283 | return c
284 |
285 | def nl(withcount=False, codemode=False):
286 | global linenum
287 | """Get input file line."""
288 | s = infile.readline()
289 | linenum += 1
290 | if not codemode:
291 | # remove any special characters - assume they were checked by pc() before
292 | # we got here.
293 | # remove any trailing comments.
294 | s = s.lstrip(' \t')
295 | s = re.sub(r'\s*(?$\.~[\]-]""", r'\\\g<0>', s)
341 | else:
342 | return re.sub(r"""[\\*/+"'<>\.~[\]-]""", r'\\\g<0>', s)
343 |
344 | def replacequoted(b):
345 | """Quotes {{raw html}} sections. Insert a backslash right before the end
346 | with &bs;, an illegal html character."""
347 | r = re.compile(r'\{\{(.*?)\}\}', re.M + re.S)
348 | m = r.search(b)
349 | while m:
350 | qb = quote(m.group(1), True)
351 |
352 | b = b[:m.start()] + qb + b[m.end():]
353 |
354 | m = r.search(b, m.start())
355 |
356 | # likewise replace $sections$ as +{{sections}}+.
357 | r = re.compile(r'(?%s<\/a>' % (link, linkname) + b[m.end():]
389 |
390 | m = r.search(b, m.start())
391 |
392 | return b
393 |
394 | def br(b):
395 | """Does simple text replacements on a block of text. ('block replacements')"""
396 | # Deal with literal backspaces.
397 | b = re.sub(r'\\\\', '&jemLITerl33talBS;', b)
398 |
399 | # Deal with {{html embedding}}.
400 | b = replacequoted(b)
401 |
402 | b = allreplace(b)
403 |
404 | # First do the URL thing.
405 | b = b.lstrip('-. \t') # remove leading spaces, tabs, dashes, dots.
406 | b = replacelinks(b)
407 |
408 | # Deal with /italics/ first because the '/' in other tags would otherwise
409 | # interfere.
410 | r = re.compile(r'(?\1', b)
412 |
413 | # Deal with *bold*.
414 | r = re.compile(r'(?\1', b)
416 |
417 | # Deal with +monospace+.
418 | r = re.compile(r'(?\1', b)
420 |
421 | # Deal with "double quotes".
422 | r = re.compile(r'(?', b)
460 |
461 | # Second to last, remove any remaining quoting backslashes.
462 | b = re.sub(r'\\(?!\\)', '', b)
463 |
464 | # Deal with literal backspaces.
465 | b = re.sub('&jemLITerl33talBS;', r'\\', b)
466 |
467 | return b
468 |
469 | def allreplace(b):
470 | """Replacements that should be done on everything."""
471 | r = re.compile(r"(?", re.M + re.S)
472 | b = re.sub(r, r'>', b)
473 |
474 | r = re.compile(r"(?>>'):
482 | hb('|\n', allreplace(l))
483 | elif l.startswith('#'): # jem upgrade this to handle not at the beginning.
484 | hb('|\n', allreplace(l))
485 | else:
486 | out(allreplace(l) + '\n')
487 |
488 | def py(l):
489 | # jem need to do much better here.
490 | l = l.rstrip()
491 | if l.startswith('>>>'):
492 | hb('|\n', allreplace(l))
493 | elif l.startswith('#'):
494 | hb('|\n', allreplace(l))
495 | else:
496 | out(allreplace(l) + '\n')
497 |
498 | def dashlist():
499 | level = 0
500 |
501 | while pc() == '-':
502 | (s, newlevel) = np(True)
503 |
504 | # first adjust list number as appropriate.
505 | if newlevel > level:
506 | for i in range(newlevel - level):
507 | if newlevel > 1:
508 | out('\n')
509 | out('
\n
')
510 | elif newlevel < level:
511 | for i in range(level - newlevel):
512 | out('
\n
\n
')
513 | else:
514 | out('
\n
')
515 |
516 | out(br(s))
517 | level = newlevel
518 |
519 | for i in range(level):
520 | out('
\n\n')
521 |
522 | def dotlist():
523 | level = 0
524 |
525 | while pc() == '.':
526 | (s, newlevel) = np(True)
527 |
528 | # first adjust list number as appropriate.
529 | if newlevel > level:
530 | for i in range(newlevel - level):
531 | if newlevel > 1:
532 | out('\n')
533 | out('\n
')
534 | elif newlevel < level:
535 | for i in range(level - newlevel):
536 | out('
\n\n
')
537 | else:
538 | out('
\n
')
539 |
540 | out(br(s))
541 | level = newlevel
542 |
543 | for i in range(level):
544 | out('
\n\n')
545 |
546 | def colonlist():
547 | out('
\n')
548 | while pc() == ':':
549 | s = np()
550 | r = re.compile(r'\s*{(.*?)(?|\n', br(defpart))
561 | hb('
|
\n', br(rest))
562 |
563 | out('
\n')
564 |
565 | def codeblock():
566 | out(conf['codeblock'])
567 | if len(g[0]):
568 | hb(conf['blocktitle'], g[0])
569 | out(conf['codeblockcontent'])
570 |
571 | if g[1] not in ('', 'pyint', 'py'):
572 | raise SyntaxError( \
573 | "couldn't handle the jandal: unrecognised syntax "
574 | "highlighting on line %d" % linenum)
575 |
576 | # Now we are handling code.
577 | # Handle \~ and ~ differently.
578 | while 1: # wait for EOF.
579 | l = nl(codemode=True)
580 | if not l:
581 | break
582 | elif l.startswith('~'):
583 | break
584 | elif l.startswith('\\~'):
585 | l = l[1:]
586 | elif l.startswith('\\{'):
587 | l = l[1:]
588 |
589 | if g[1] == 'pyint':
590 | pyint(l)
591 | elif g[1] == 'py':
592 | py(l)
593 | else:
594 | out(allreplace(l))
595 |
596 | out(conf['codeblockend'])
597 |
598 | # load the conf.
599 | conf = parseconf(confnames)
600 |
601 | # Get the file started with the firstbit.
602 | out(conf['firstbit'])
603 |
604 | linenum = 0
605 |
606 | menu = None
607 | footer = True
608 | if pc() == '#':
609 | l = infile.readline()
610 | linenum += 1
611 | if l.startswith('# jemdoc: '):
612 | l = l[len('# jemdoc: '):]
613 | a = l.split(',')
614 | # jem only handle one argument for now.
615 | for b in a:
616 | b = b.strip()
617 | if b.startswith('menu'):
618 | sidemenu = True
619 | r = re.compile(r'(?|\n' % (c, c), br(s))
678 |
679 | # look for comments.
680 | elif p == '#':
681 | nl()
682 |
683 | elif p == '\n':
684 | nl()
685 |
686 | # look for blocks.
687 | elif p == '~':
688 | nl()
689 | if infoblock:
690 | out(conf['infoblockend'])
691 | infoblock = False
692 | nl()
693 | continue
694 | else:
695 | if pc() == '{':
696 | l = br(nl())
697 | r = re.compile(r'(?|
\n', s)
721 |
722 | if footer:
723 | s = time.strftime('%F %R:%S %Z', time.localtime(time.time()))
724 | out(conf['footerstart'])
725 | hb(conf['lastupdated'], s)
726 | out(conf['footerend'])
727 |
728 | if menu:
729 | out(conf['menulastbit'])
730 | else:
731 | out(conf['nomenulastbit'])
732 |
733 | out(conf['bodyend'])
734 |
735 | if outfile is not sys.stdout:
736 | outfile.close()
737 |
--------------------------------------------------------------------------------
/www/dist/jemdoc.py-0.3.0:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | """
4 | jemdoc: light markup.
5 |
6 | version 0.3.0, November 2007.
7 | """
8 |
9 | # Copyright (C) 2007 Jacob Mattingley.
10 | #
11 | # This file is part of jemdoc.
12 | #
13 | # jemdoc is free software; you can redistribute it and/or modify it under the
14 | # terms of the GNU General Public License as published by the Free Software
15 | # Foundation; either version 3 of the License, or (at your option) any later
16 | # version.
17 | #
18 | # jemdoc is distributed in the hope that it will be useful, but WITHOUT ANY
19 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License along with
23 | # this program. If not, see .
24 |
25 | import sys
26 | import os
27 | import re
28 | import time
29 | import StringIO
30 |
31 | class controlstruct(object):
32 | def __init__(self, infile, outfile, conf):
33 | self.inf = infile
34 | self.outf = outfile
35 | self.conf = conf
36 | self.linenum = 0
37 |
38 | # better checking of arguments?
39 | def showhelp():
40 | a = """Usage: jemdoc [OPTIONS] [SOURCEFILE]
41 | Produces html markup from a jemdoc SOURCEFILE.
42 |
43 | Most of the time you can use jemdoc without any additional flags.
44 | For example, typing
45 |
46 | jemdoc index.jemdoc
47 |
48 | will produce an index.html, using a default configuration. You can
49 | change the output file by using -o OUTFILE, for example
50 |
51 | jemdoc -o html/main.html index.jemdoc
52 |
53 | Some configuration options can be overridden by specifying a
54 | configuration file. You can use
55 |
56 | jemdoc --show-config
57 |
58 | to print a sample configuration file (which includes all of the
59 | default options). Any or all of the configuration [blocks] can be
60 | overwritten by including them in a configuration file, and running,
61 | for example,
62 |
63 | jemdoc -c mywebsite.f.conf index.jemdoc
64 |
65 | See http://jemdoc.jaboc.net/ for more details.
66 | """
67 | b = ''
68 | for l in a.splitlines(True):
69 | if l.startswith(' '*4):
70 | b += l[4:]
71 | else:
72 | b += l
73 |
74 | print b
75 |
76 | def standardconf():
77 | a = """[firstbit]
78 |
80 |
81 |
82 |
83 |
84 |
85 | [defaultcss]
86 |
87 |
88 | [windowtitle]
89 | # used in header for window title.
90 | |
91 |
92 | [doctitle]
93 | # used at top of document.
94 |
\n', s)
891 |
892 | if footer:
893 | s = time.strftime('%F %R:%S %Z', time.localtime(time.time()))
894 | out(f.outf, f.conf['footerstart'])
895 | hb(f.outf, f.conf['lastupdated'], s)
896 | out(f.outf, f.conf['footerend'])
897 |
898 | if menu:
899 | out(f.outf, f.conf['menulastbit'])
900 | else:
901 | out(f.outf, f.conf['nomenulastbit'])
902 |
903 | out(f.outf, f.conf['bodyend'])
904 |
905 | if f.outf is not sys.stdout:
906 | f.outf.close()
907 |
908 | def main():
909 | if len(sys.argv) == 1 or sys.argv[1] in ('--help', '-h'):
910 | showhelp()
911 | raise SystemExit
912 | if sys.argv[1] == '--show-config':
913 | print standardconf()
914 | raise SystemExit
915 |
916 | outoverride = False
917 | confoverride = False
918 | outname = None
919 | confnames = []
920 | for i in range(1, len(sys.argv), 2):
921 | if sys.argv[i] == '-o':
922 | if outoverride:
923 | raise RuntimeError("only one output file / directory, please")
924 | outname = sys.argv[i+1]
925 | outoverride = True
926 | elif sys.argv[i] == '-c':
927 | if confoverride:
928 | raise RuntimeError("only one config file, please")
929 | confnames.append(sys.argv[i+1])
930 | confoverride = True
931 | elif sys.argv[i].startswith('-'):
932 | raise RuntimeError('unrecognised argument %s, try --help' % sys.argv[i])
933 | else:
934 | break
935 |
936 | conf = parseconf(confnames)
937 |
938 | innames = []
939 | for j in range(i, len(sys.argv)):
940 | # First, if not a file and no dot, try opening .jemdoc. Otherwise, fall back
941 | # to just doing exactly as asked.
942 | inname = sys.argv[j]
943 | if not os.path.isfile(inname) and '.' not in inname:
944 | inname += '.jemdoc'
945 |
946 | innames.append(inname)
947 |
948 | if outname is not None and not os.path.isdir(outname) and len(innames) > 1:
949 | raise RuntimeError('cannot handle one outfile with multiple infiles')
950 |
951 | for inname in innames:
952 | if outname is None:
953 | thisout = re.sub(r'.jemdoc$', '', inname) + '.html'
954 | elif os.path.isdir(outname):
955 | # if directory, prepend directory to automatically generated name.
956 | thisout = outname + re.sub(r'.jemdoc$', '', inname) + '.html'
957 | else:
958 | thisout = outname
959 |
960 | infile = open(inname)
961 | outfile = open(thisout, 'w')
962 |
963 | f = controlstruct(infile, outfile, conf)
964 | procfile(f)
965 |
966 | #
967 | if __name__ == '__main__':
968 | main()
969 |
--------------------------------------------------------------------------------
/www/dist/jemdoc.py-0.3.4:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | """
4 | jemdoc: light markup, see http://jemdoc.jaboc.net/.
5 |
6 | version 0.3.4, November 2007.
7 | """
8 |
9 | # Copyright (C) 2007 Jacob Mattingley.
10 | #
11 | # This file is part of jemdoc.
12 | #
13 | # jemdoc is free software; you can redistribute it and/or modify it under the
14 | # terms of the GNU General Public License as published by the Free Software
15 | # Foundation; either version 3 of the License, or (at your option) any later
16 | # version.
17 | #
18 | # jemdoc is distributed in the hope that it will be useful, but WITHOUT ANY
19 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License along with
23 | # this program. If not, see .
24 |
25 | import sys
26 | import os
27 | import re
28 | import time
29 | import StringIO
30 |
31 | class controlstruct(object):
32 | def __init__(self, infile, outfile=None, conf=None):
33 | self.inf = infile
34 | self.outf = outfile
35 | self.conf = conf
36 | self.linenum = 0
37 |
38 | # better checking of arguments?
39 | def showhelp():
40 | a = """Usage: jemdoc [OPTIONS] [SOURCEFILE]
41 | Produces html markup from a jemdoc SOURCEFILE.
42 |
43 | Most of the time you can use jemdoc without any additional flags.
44 | For example, typing
45 |
46 | jemdoc index.jemdoc
47 |
48 | will produce an index.html, using a default configuration. You can
49 | change the output file by using -o OUTFILE, for example
50 |
51 | jemdoc -o html/main.html index.jemdoc
52 |
53 | Some configuration options can be overridden by specifying a
54 | configuration file. You can use
55 |
56 | jemdoc --show-config
57 |
58 | to print a sample configuration file (which includes all of the
59 | default options). Any or all of the configuration [blocks] can be
60 | overwritten by including them in a configuration file, and running,
61 | for example,
62 |
63 | jemdoc -c mywebsite.conf index.jemdoc
64 |
65 | See http://jemdoc.jaboc.net/ for more details.
66 | """
67 | b = ''
68 | for l in a.splitlines(True):
69 | if l.startswith(' '*4):
70 | b += l[4:]
71 | else:
72 | b += l
73 |
74 | print b
75 |
76 | def standardconf():
77 | a = """[firstbit]
78 |
80 |
81 |
82 |
83 |
84 |
85 | [defaultcss]
86 |
87 |
88 | [windowtitle]
89 | # used in header for window title.
90 | |
91 |
92 | [doctitle]
93 | # used at top of document.
94 |
\n', s)
891 |
892 | if footer:
893 | s = time.strftime('%Y-%m-%d %H:%M:%S %Z', time.localtime(time.time()))
894 | out(f.outf, f.conf['footerstart'])
895 | hb(f.outf, f.conf['lastupdated'], s)
896 | out(f.outf, f.conf['footerend'])
897 |
898 | if menu:
899 | out(f.outf, f.conf['menulastbit'])
900 | else:
901 | out(f.outf, f.conf['nomenulastbit'])
902 |
903 | out(f.outf, f.conf['bodyend'])
904 |
905 | if f.outf is not sys.stdout:
906 | f.outf.close()
907 |
908 | def main():
909 | if len(sys.argv) == 1 or sys.argv[1] in ('--help', '-h'):
910 | showhelp()
911 | raise SystemExit
912 | if sys.argv[1] == '--show-config':
913 | print standardconf()
914 | raise SystemExit
915 |
916 | outoverride = False
917 | confoverride = False
918 | outname = None
919 | confnames = []
920 | for i in range(1, len(sys.argv), 2):
921 | if sys.argv[i] == '-o':
922 | if outoverride:
923 | raise RuntimeError("only one output file / directory, please")
924 | outname = sys.argv[i+1]
925 | outoverride = True
926 | elif sys.argv[i] == '-c':
927 | if confoverride:
928 | raise RuntimeError("only one config file, please")
929 | confnames.append(sys.argv[i+1])
930 | confoverride = True
931 | elif sys.argv[i].startswith('-'):
932 | raise RuntimeError('unrecognised argument %s, try --help' % sys.argv[i])
933 | else:
934 | break
935 |
936 | conf = parseconf(confnames)
937 |
938 | innames = []
939 | for j in range(i, len(sys.argv)):
940 | # First, if not a file and no dot, try opening .jemdoc. Otherwise, fall back
941 | # to just doing exactly as asked.
942 | inname = sys.argv[j]
943 | if not os.path.isfile(inname) and '.' not in inname:
944 | inname += '.jemdoc'
945 |
946 | innames.append(inname)
947 |
948 | if outname is not None and not os.path.isdir(outname) and len(innames) > 1:
949 | raise RuntimeError('cannot handle one outfile with multiple infiles')
950 |
951 | for inname in innames:
952 | if outname is None:
953 | thisout = re.sub(r'.jemdoc$', '', inname) + '.html'
954 | elif os.path.isdir(outname):
955 | # if directory, prepend directory to automatically generated name.
956 | thisout = outname + re.sub(r'.jemdoc$', '', inname) + '.html'
957 | else:
958 | thisout = outname
959 |
960 | infile = open(inname)
961 | outfile = open(thisout, 'w')
962 |
963 | f = controlstruct(infile, outfile, conf)
964 | procfile(f)
965 |
966 | #
967 | if __name__ == '__main__':
968 | main()
969 |
--------------------------------------------------------------------------------
/www/dist/jemdoc.py-0.3.5:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | """
4 | jemdoc: light markup, see http://jemdoc.jaboc.net/.
5 |
6 | version 0.3.5, 2007-11-26.
7 | """
8 |
9 | # Copyright (C) 2007 Jacob Mattingley.
10 | #
11 | # This file is part of jemdoc.
12 | #
13 | # jemdoc is free software; you can redistribute it and/or modify it under the
14 | # terms of the GNU General Public License as published by the Free Software
15 | # Foundation; either version 3 of the License, or (at your option) any later
16 | # version.
17 | #
18 | # jemdoc is distributed in the hope that it will be useful, but WITHOUT ANY
19 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 | #
22 | # You should have received a copy of the GNU General Public License along with
23 | # this program. If not, see .
24 |
25 | import sys
26 | import os
27 | import re
28 | import time
29 | import StringIO
30 |
31 | class controlstruct(object):
32 | def __init__(self, infile, outfile=None, conf=None, inname=None):
33 | self.inname = inname
34 | self.inf = infile
35 | self.outf = outfile
36 | self.conf = conf
37 | self.linenum = 0
38 |
39 | # better checking of arguments?
40 | def showhelp():
41 | a = """Usage: jemdoc [OPTIONS] [SOURCEFILE]
42 | Produces html markup from a jemdoc SOURCEFILE.
43 |
44 | Most of the time you can use jemdoc without any additional flags.
45 | For example, typing
46 |
47 | jemdoc index.jemdoc
48 |
49 | will produce an index.html, using a default configuration. You can
50 | change the output file by using -o OUTFILE, for example
51 |
52 | jemdoc -o html/main.html index.jemdoc
53 |
54 | Some configuration options can be overridden by specifying a
55 | configuration file. You can use
56 |
57 | jemdoc --show-config
58 |
59 | to print a sample configuration file (which includes all of the
60 | default options). Any or all of the configuration [blocks] can be
61 | overwritten by including them in a configuration file, and running,
62 | for example,
63 |
64 | jemdoc -c mywebsite.conf index.jemdoc
65 |
66 | See http://jemdoc.jaboc.net/ for more details.
67 | """
68 | b = ''
69 | for l in a.splitlines(True):
70 | if l.startswith(' '*4):
71 | b += l[4:]
72 | else:
73 | b += l
74 |
75 | print b
76 |
77 | def standardconf():
78 | a = """[firstbit]
79 |
81 |
82 |
83 |
84 |
85 |
86 | [defaultcss]
87 |
88 |
89 | [windowtitle]
90 | # used in header for window title.
91 | |
92 |
93 | [doctitle]
94 | # used at top of document.
95 |
\n', s)
934 |
935 | if showlastupdated or showsourcelink:
936 | out(f.outf, f.conf['footerstart'])
937 | if showlastupdated:
938 | s = time.strftime('%Y-%m-%d %H:%M:%S %Z', time.localtime(time.time()))
939 | hb(f.outf, f.conf['lastupdated'], s)
940 | if showsourcelink:
941 | hb(f.outf, f.conf['sourcelink'], f.inname)
942 | out(f.outf, f.conf['footerend'])
943 |
944 | if menu:
945 | out(f.outf, f.conf['menulastbit'])
946 | else:
947 | out(f.outf, f.conf['nomenulastbit'])
948 |
949 | out(f.outf, f.conf['bodyend'])
950 |
951 | if f.outf is not sys.stdout:
952 | f.outf.close()
953 |
954 | def main():
955 | if len(sys.argv) == 1 or sys.argv[1] in ('--help', '-h'):
956 | showhelp()
957 | raise SystemExit
958 | if sys.argv[1] == '--show-config':
959 | print standardconf()
960 | raise SystemExit
961 |
962 | outoverride = False
963 | confoverride = False
964 | outname = None
965 | confnames = []
966 | for i in range(1, len(sys.argv), 2):
967 | if sys.argv[i] == '-o':
968 | if outoverride:
969 | raise RuntimeError("only one output file / directory, please")
970 | outname = sys.argv[i+1]
971 | outoverride = True
972 | elif sys.argv[i] == '-c':
973 | if confoverride:
974 | raise RuntimeError("only one config file, please")
975 | confnames.append(sys.argv[i+1])
976 | confoverride = True
977 | elif sys.argv[i].startswith('-'):
978 | raise RuntimeError('unrecognised argument %s, try --help' % sys.argv[i])
979 | else:
980 | break
981 |
982 | conf = parseconf(confnames)
983 |
984 | innames = []
985 | for j in range(i, len(sys.argv)):
986 | # First, if not a file and no dot, try opening .jemdoc. Otherwise, fall back
987 | # to just doing exactly as asked.
988 | inname = sys.argv[j]
989 | if not os.path.isfile(inname) and '.' not in inname:
990 | inname += '.jemdoc'
991 |
992 | innames.append(inname)
993 |
994 | if outname is not None and not os.path.isdir(outname) and len(innames) > 1:
995 | raise RuntimeError('cannot handle one outfile with multiple infiles')
996 |
997 | for inname in innames:
998 | if outname is None:
999 | thisout = re.sub(r'.jemdoc$', '', inname) + '.html'
1000 | elif os.path.isdir(outname):
1001 | # if directory, prepend directory to automatically generated name.
1002 | thisout = outname + re.sub(r'.jemdoc$', '', inname) + '.html'
1003 | else:
1004 | thisout = outname
1005 |
1006 | infile = open(inname)
1007 | outfile = open(thisout, 'w')
1008 |
1009 | f = controlstruct(infile, outfile, conf, inname)
1010 | procfile(f)
1011 |
1012 | #
1013 | if __name__ == '__main__':
1014 | main()
1015 |
--------------------------------------------------------------------------------
/www/dist/jemdoc.vim:
--------------------------------------------------------------------------------
1 | " Vim syntax file
2 | " Language: jemdoc
3 | " Author: Jacob Mattingley (inspired by
4 | " Stuart Rackham's asciidoc).
5 | " Last Change: jemdoc 0.1.1
6 | " URL: http://jaboc.net/
7 | " Licence: GPL (http://www.gnu.org)
8 | " Remarks: Vim 6 or greater
9 | " Limitations: See 'Appendix J: Vim Syntax Highlighter' in the AsciiDoc 'User
10 | " Guide'.
11 |
12 | "if exists("b:current_syntax")
13 | " finish
14 | "endif
15 |
16 | syn clear
17 | syn sync fromstart " change this if it gets slow.
18 | syn sync linebreaks=1
19 |
20 | " Run :help syn-priority to review syntax matching priority.
21 | "
22 | syn keyword jemdocToDo TODO FIXME XXX ZZZ
23 | syn match jemdocQuotedCharError /\\./
24 | syn match jemdocQuotedChar /\\[[\]\\\*{}\/\.\-\+"=~np#%RC`'\$%]/
25 | syn match jemdocListBullet /^\s*[-.:]\+\s/
26 | syn match jemdocCommentLine "\\\@jemdoc.py}}
6 | (+v0.7.3+). You can also download this [dist/jemdoc.css example css
7 | file] to get you started. You can easily modify the css to adjust colours, fonts
8 | and general layout elements to your taste.
9 |
10 | You may like to %sudo cp jemdoc.py /usr/bin/jemdoc%
11 | so that you can just type
12 | +jemdoc+; alternatively, you could add a line to your %~/.bashrc% or
13 | similar like %alias jemdoc='/somepath/jemdoc.py'%. Remember to +chmod \+x+ your
14 | file to make it executable.
15 |
16 | jemdoc requires Python~2.3 or later. If you have a working installation of
17 | Python, you should be ready to go. This includes all Macs, and almost any
18 | fairly modern unix or linux.
19 |
20 | [dist/ Old versions] can still be found. Mahesh Shastry provides a package with
21 | [http://www.personal.psu.edu/mcs312/miscellany.html\#portablejemdoc
22 | jemdoc compiled for Windows].
23 |
24 | == Where to next?
25 | Read about [using.html how to use jemdoc], check out an [example.html example
26 | page], then refer to the [cheatsheet.html cheat sheet] once you're underway.
27 | You could also download sample jemdoc code, like the [index.jemdoc index page]
28 | for this website.
29 |
--------------------------------------------------------------------------------
/www/example.jemdoc:
--------------------------------------------------------------------------------
1 | # jemdoc: menu{MENU}{example.html}, addcss{example.css}
2 | = jemdoc -- example page
3 |
4 | ~~~
5 | This page shows example jemdoc source and output side by side. (The spacing of
6 | the `page' on the left is consequently incorrect.)
7 | ~~~
8 |
9 | ## jemdoc: start now.
10 | ~~~
11 | {}{raw}
12 |
37 | ~~~
38 | If the first line of the file starts with +\# jemdoc+, special functions like
39 | [menu.html menus] will be used.
40 |
41 | ~~~
42 | {}{raw}
43 |
44 |
45 | ~~~
46 | ~~~
47 | {}{jemdoc}
48 | If the first line of the file starts with +\# jemdoc+, special functions like
49 | [menu.html menus] will be used.
50 |
51 | ~~~
52 | ~~~
53 | {}{raw}
54 |
55 |
56 | ~~~
57 | == Example
58 | Here are some *text* /features/. I could [http://cvxmod.net/ link somewhere] or
59 | insert a raw link to another page like [download.html]. I could use
60 | +monospace+, too.
61 |
62 | ~~~
63 | {}{raw}
64 |
65 |
66 | ~~~
67 | ~~~
68 | {}{jemdoc}
69 | == Example
70 | Here are some *text* /features/. I could [http://cvxmod.net/ link somewhere] or
71 | insert a raw link to another page like [download.html]. I could use
72 | +monospace+, too.
73 |
74 | ~~~
75 | ~~~
76 | {}{raw}
77 |
78 |
79 | ~~~
80 | I could write special characters like
81 | \#, \$ and \+ by just using a backslash
82 | (\\) in front of those characters. Or
83 | automatically detect an
84 | [jacobm@stanford.edu email address].
85 |
86 | ~~~
87 | {}{raw}
88 |
89 |
90 | ~~~
91 | ~~~
92 | {}{jemdoc}
93 | I could write special characters like
94 | \#, \$ and \+ by just using a backslash
95 | (\\) in front of those characters. Or
96 | automatically detect an
97 | [jacobm@stanford.edu email address].
98 |
99 | ~~~
100 | ~~~
101 | {}{raw}
102 |
103 |
104 | ~~~
105 | ~~~
106 | Save the file as +index.jemdoc+, say, and simply
107 | call +jemdoc index+ (after [download.html
108 | downloading jemdoc], of course).
109 | ~~~
110 |
111 | ~~~
112 | {}{raw}
113 |
129 | ~~~
130 | == Next bit, next heading level two
131 | === Getting into level three now
132 |
133 | ~~~
134 | {}{raw}
135 |
136 |
137 | ~~~
138 | ~~~
139 | {}{jemdoc}
140 | == Next bit, next heading level two
141 | === Getting into level three now
142 |
143 | ~~~
144 | ~~~
145 | {}{raw}
146 |
147 |
148 | ~~~
149 | Why not use a list
150 | - to explain the way you do lists?
151 | - to demonstrate how a line\n
152 | break might work?
153 |
154 | ~~~
155 | {}{raw}
156 |
157 |
158 | ~~~
159 | ~~~
160 | {}{jemdoc}
161 | Why not use a list
162 | - to explain the way you do lists?
163 | - to demonstrate how a line\n
164 | break might work?
165 |
166 | ~~~
167 | ~~~
168 | {}{raw}
169 |
170 |
171 | ~~~
172 | Or perhaps a
173 | . Multilevel
174 | .. Numbered list
175 | .. Is more
176 | . Useful?
177 |
178 | ~~~
179 | {}{raw}
180 |
181 |
182 | ~~~
183 | ~~~
184 | {}{jemdoc}
185 | Or perhaps a
186 | . Multilevel
187 | .. Numbered list
188 | .. Is more
189 | . Useful?
190 |
191 | ~~~
192 | ~~~
193 | {}{raw}
194 |
195 |
196 | ~~~
197 | : {Definition} lists, especially when there are
198 | many definitions
199 | : {Can be useful} for explaining things
200 |
201 | ~~~
202 | {}{raw}
203 |
204 |
205 | ~~~
206 | ~~~
207 | {}{jemdoc}
208 | : {Definition} lists, especially when there are
209 | many definitions
210 | : {Can be useful} for explaining things
211 |
212 | ~~~
213 | ~~~
214 | {}{raw}
215 |
216 |
217 | ~~~
218 | == Finally, a few more blocks
219 | This `section' features "smart quotes".
220 |
221 | ~~~
222 | {}{raw}
223 |
224 |
225 | ~~~
226 | ~~~
227 | {}{jemdoc}
228 | == Finally, a few more blocks
229 | This `section' features "smart quotes".
230 |
231 | ~~~
232 | ~~~
233 | {}{raw}
234 |
235 |
236 | ~~~
237 | ~~~
238 | {Simple block}
239 | This is a simple text block, with a title. Notice how the previous line has only
240 | one set of braces (\{\}).
241 | ~~~
242 |
243 | ~~~
244 | {}{raw}
245 |
246 |
247 | ~~~
248 | ~~~
249 | {}{jemdoc}
250 | \~~~
251 | {Simple block}
252 | This is a simple text block, with a title. Notice how the previous line has only
253 | one set of braces (\{\}).
254 | \~~~
255 |
256 | ~~~
257 | ~~~
258 | {}{raw}
259 |
309 | ~~~
310 | You might need 2--3 different-sized dashes---they can be useful. Now we're done!
311 | ~~~
312 | {}{raw}
313 |
314 |
315 | ~~~
316 | ~~~
317 | {}{jemdoc}
318 | You might need 2--3 different-sized dashes---they can be useful. Now we're done!
319 | ~~~
320 | ~~~
321 | {}{raw}
322 |
323 | ~~~
324 |
--------------------------------------------------------------------------------
/www/exampleIN.jemdoc:
--------------------------------------------------------------------------------
1 | # jemdoc: menu{MENU}{example.html}, addcss{example.css}
2 | = jemdoc -- example page
3 |
4 | ~~~
5 | This page shows example jemdoc source and output side by side. (The spacing of
6 | the `page' on the left is consequently incorrect.)
7 | ~~~
8 |
9 | ## jemdoc: start now.
10 | # jemdoc: menu{MENU}{example.html}
11 | = jemdoc -- example page
12 | [http://stanford.edu/~jacobm/ Jacob Mattingley]
13 | ([jacobm@stanford.edu])
14 |
15 | If the first line of the file starts with +\# jemdoc+, special functions like
16 | [menu.html menus] will be used.
17 |
18 | == Example
19 | Here are some *text* /features/. I could [http://cvxmod.net/ link somewhere] or
20 | insert a raw link to another page like [download.html]. I could use
21 | +monospace+, too.
22 |
23 | I could write special characters like
24 | \#, \$ and \+ by just using a backslash
25 | (\\) in front of those characters. Or
26 | automatically detect an
27 | [jacobm@stanford.edu email address].
28 |
29 | ~~~
30 | Save the file as +index.jemdoc+, say, and simply
31 | call +jemdoc index+ (after [download.html
32 | downloading jemdoc], of course).
33 | ~~~
34 |
35 | == Next bit, next heading level two
36 | === Getting into level three now
37 |
38 | Why not use a list
39 | - to explain the way you do lists?
40 | - to demonstrate how a line\n
41 | break might work?
42 |
43 | Or perhaps a
44 | . Multilevel
45 | .. Numbered list
46 | .. Is more
47 | . Useful?
48 |
49 | : {Definition} lists, especially when there are
50 | many definitions
51 | : {Can be useful} for explaining things
52 |
53 | == Finally, a few more blocks
54 | This `section' features "smart quotes".
55 |
56 | ~~~
57 | {Simple block}
58 | This is a simple text block, with a title. Notice how the previous line has only
59 | one set of braces (\{\}).
60 | ~~~
61 |
62 | ~~~
63 | {Interactive Python listing}{pyint}
64 | >>> print 'Interactive Python code.'
65 | 'Interactive Python code.'
66 | ~~~
67 |
68 | ~~~
69 | {}{}
70 | Plain code block with no title.
71 | ~~~
72 |
73 | You might need 2--3 different-sized dashes---they can be useful. Now we're done!
74 |
--------------------------------------------------------------------------------
/www/extra.jemdoc:
--------------------------------------------------------------------------------
1 | # jemdoc: menu{MENU}{extra.html}
2 | = jemdoc -- extra syntax elements
3 |
4 | These are some extended syntax options that may come in useful.
5 |
6 | == Left aligned image blocks
7 | As seen [http://stanford.edu/~jacobm here], for example,
8 | left-aligned image blocks place an image and allow ordinary jemdoc marked-up
9 | text to flow around the right-hand side.
10 | ~~~
11 | {Left-aligned image block syntax}{}
12 | \~~~
13 | \{}{img_left}{FILENAME.IMG}{alt text}{WIDTHpx}{HEIGHTpx}{IMGLINKTARGET}
14 | Ordinary jemdoc markup goes here.
15 | \~~~
16 | ~~~
17 |
18 | All arguments may be left blank, though you should specify an image filename,
19 | and alt text should be descriptive for reasons like
20 | [http://en.wikipedia.org/wiki/Wikipedia:Alternative_text_for_images those given
21 | by Wikipedia].
22 |
23 | == Raw blocks
24 | When placing large amounts of raw html, you should use a raw block instead of
25 | +\{\{inline html escaping\}\}+. As well as cleaner syntax, raw blocks will avoid
26 | having +
+ tags in the wrong places.
27 | ~~~
28 | {Raw block syntax}{}
29 | \~~~
30 | \{}{raw}
31 | Any text here will be copied straight to the output file without processing.
32 | \~~~
33 | ~~~
34 |
35 | == Other character sets
36 | Here's a quick example of how to include text in a language with a different
37 | character set.
38 |
39 | To include Korean ({{}}한국말{{}}),
40 | use something like this:
41 | ~~~
42 | {}{}
43 | {{}}한국말{{}}
44 | ~~~
45 |
46 | ([jacobm@stanford.edu Let me know] if you need better support for your
47 | language.)
48 |
49 | == Including other files
50 | The line
51 | ~~~
52 | {}{}
53 | \#include{otherfile.jemdoc}
54 | ~~~
55 | will include the contents of +otherfile.jemdoc+ as if the contents were actually
56 | in the ordinary input file (that is, with full jemdoc substitutions).
57 | The line
58 | ~~~
59 | {}{}
60 | \#includeraw{otherfile.html}
61 | ~~~
62 | will copy the contents of +otherfile.html+ verbatim to the current position in
63 | the output file (that is, without any jemdoc substitutions).
64 |
65 | == Other packages
66 | - [http://www.polytekniker.dk/about.html Jacob Grunnet] has written
67 | [http://bibover.polytekniker.dk Bibover], a bibtex reference extension for
68 | jemdoc.
69 | - [http://www.seas.upenn.edu/~nghiem/ Truong Nghiem] has written a
70 | [http://www.seas.upenn.edu/~nghiem/software.html filter for exporting
71 | references from JabRef to
72 | jemdoc].
73 |
--------------------------------------------------------------------------------
/www/htmlchanges.jemdoc:
--------------------------------------------------------------------------------
1 | # jemdoc: menu{MENU}{htmlchanges.html}
2 | = jemdoc -- html changes
3 |
4 | jemdoc has a built-in default configuration. This configuration includes the
5 | particular html tags used when producing html. If you wish to adjust the html
6 | that jemdoc produces, you can provide a configuration file to override the
7 | built-in defaults.
8 |
9 | == Example html change
10 | Suppose you wanted to add [http://www.google.com/analytics/ Google
11 | Analytics] tracking to your website. That requires adding a short section of
12 | html before the +