PageRenderTime 65ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/old/txt2tags-2.6.py

http://txt2tags.googlecode.com/
Python | 5987 lines | 5359 code | 249 blank | 379 comment | 250 complexity | 79cde3d3abf5bbc7e2598b375572527c MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, WTFPL

Large files files are truncated, but you can click here to view the full file

  1. #!/usr/bin/env python
  2. # txt2tags - generic text conversion tool
  3. # http://txt2tags.org
  4. #
  5. # Copyright 2001-2010 Aurelio Jargas
  6. #
  7. # License: http://www.gnu.org/licenses/gpl-2.0.txt
  8. # Subversion: http://svn.txt2tags.org
  9. # Bug tracker: http://bugs.txt2tags.org
  10. #
  11. ########################################################################
  12. #
  13. # BORING CODE EXPLANATION AHEAD
  14. #
  15. # Just read it if you wish to understand how the txt2tags code works.
  16. #
  17. ########################################################################
  18. #
  19. # The code that [1] parses the marked text is separated from the
  20. # code that [2] insert the target tags.
  21. #
  22. # [1] made by: def convert()
  23. # [2] made by: class BlockMaster
  24. #
  25. # The structures of the marked text are identified and its contents are
  26. # extracted into a data holder (Python lists and dictionaries).
  27. #
  28. # When parsing the source file, the blocks (para, lists, quote, table)
  29. # are opened with BlockMaster, right when found. Then its contents,
  30. # which spans on several lines, are feeded into a special holder on the
  31. # BlockMaster instance. Just when the block is closed, the target tags
  32. # are inserted for the full block as a whole, in one pass. This way, we
  33. # have a better control on blocks. Much better than the previous line by
  34. # line approach.
  35. #
  36. # In other words, whenever inside a block, the parser *holds* the tag
  37. # insertion process, waiting until the full block is read. That was
  38. # needed primary to close paragraphs for the XHTML target, but
  39. # proved to be a very good adding, improving many other processing.
  40. #
  41. # -------------------------------------------------------------------
  42. #
  43. # These important classes are all documented:
  44. # CommandLine, SourceDocument, ConfigMaster, ConfigLines.
  45. #
  46. # There is a RAW Config format and all kind of configuration is first
  47. # converted to this format. Then a generic method parses it.
  48. #
  49. # These functions get information about the input file(s) and take
  50. # care of the init processing:
  51. # get_infiles_config(), process_source_file() and convert_this_files()
  52. #
  53. ########################################################################
  54. #XXX Python coding warning
  55. # Avoid common mistakes:
  56. # - do NOT use newlist=list instead newlist=list[:]
  57. # - do NOT use newdic=dic instead newdic=dic.copy()
  58. # - do NOT use dic[key] instead dic.get(key)
  59. # - do NOT use del dic[key] without has_key() before
  60. #XXX Smart Image Align don't work if the image is a link
  61. # Can't fix that because the image is expanded together with the
  62. # link, at the linkbank filling moment. Only the image is passed
  63. # to parse_images(), not the full line, so it is always 'middle'.
  64. #XXX Paragraph separation not valid inside Quote
  65. # Quote will not have <p></p> inside, instead will close and open
  66. # again the <blockquote>. This really sux in CSS, when defining a
  67. # different background color. Still don't know how to fix it.
  68. #XXX TODO (maybe)
  69. # New mark or macro which expands to an anchor full title.
  70. # It is necessary to parse the full document in this order:
  71. # DONE 1st scan: HEAD: get all settings, including %!includeconf
  72. # DONE 2nd scan: BODY: expand includes & apply %!preproc
  73. # 3rd scan: BODY: read titles and compose TOC info
  74. # 4th scan: BODY: full parsing, expanding [#anchor] 1st
  75. # Steps 2 and 3 can be made together, with no tag adding.
  76. # Two complete body scans will be *slow*, don't know if it worths.
  77. # One solution may be add the titles as postproc rules
  78. ##############################################################################
  79. # User config (1=ON, 0=OFF)
  80. USE_I18N = 1 # use gettext for i18ned messages? (default is 1)
  81. COLOR_DEBUG = 1 # show debug messages in colors? (default is 1)
  82. BG_LIGHT = 0 # your terminal background color is light (default is 0)
  83. HTML_LOWER = 0 # use lowercased HTML tags instead upper? (default is 0)
  84. ##############################################################################
  85. # These are all the core Python modules used by txt2tags (KISS!)
  86. import re, os, sys, time, getopt
  87. # The CSV module is new in Python version 2.3
  88. try:
  89. import csv
  90. except ImportError:
  91. csv = None
  92. # Program information
  93. my_url = 'http://txt2tags.org'
  94. my_name = 'txt2tags'
  95. my_email = 'verde@aurelio.net'
  96. my_version = '2.6'
  97. # i18n - just use if available
  98. if USE_I18N:
  99. try:
  100. import gettext
  101. # If your locale dir is different, change it here
  102. cat = gettext.Catalog('txt2tags',localedir='/usr/share/locale/')
  103. _ = cat.gettext
  104. except:
  105. _ = lambda x:x
  106. else:
  107. _ = lambda x:x
  108. # FLAGS : the conversion related flags , may be used in %!options
  109. # OPTIONS : the conversion related options, may be used in %!options
  110. # ACTIONS : the other behavior modifiers, valid on command line only
  111. # MACROS : the valid macros with their default values for formatting
  112. # SETTINGS: global miscellaneous settings, valid on RC file only
  113. # NO_TARGET: actions that don't require a target specification
  114. # NO_MULTI_INPUT: actions that don't accept more than one input file
  115. # CONFIG_KEYWORDS: the valid %!key:val keywords
  116. #
  117. # FLAGS and OPTIONS are configs that affect the converted document.
  118. # They usually have also a --no-<option> to turn them OFF.
  119. #
  120. # ACTIONS are needed because when doing multiple input files, strange
  121. # behavior would be found, as use command line interface for the
  122. # first file and gui for the second. There is no --no-<action>.
  123. # --version and --help inside %!options are also odd
  124. #
  125. TARGETS = 'html xhtml sgml dbk tex lout man mgp wiki gwiki doku pmw moin pm6 txt art adoc creole'.split()
  126. TARGETS.sort()
  127. FLAGS = {'headers' :1 , 'enum-title' :0 , 'mask-email' :0 ,
  128. 'toc-only' :0 , 'toc' :0 , 'rc' :1 ,
  129. 'css-sugar' :0 , 'css-suggar' :0 , 'css-inside' :0 ,
  130. 'quiet' :0 , 'slides' :0 }
  131. OPTIONS = {'target' :'', 'toc-level' :3 , 'style' :'',
  132. 'infile' :'', 'outfile' :'', 'encoding' :'',
  133. 'config-file':'', 'split' :0 , 'lang' :'',
  134. 'width' :0 , 'height' :0 , 'art-chars' :'',
  135. 'show-config-value':''}
  136. ACTIONS = {'help' :0 , 'version' :0 , 'gui' :0 ,
  137. 'verbose' :0 , 'debug' :0 , 'dump-config':0 ,
  138. 'dump-source':0 , 'targets' :0}
  139. MACROS = {'date' : '%Y%m%d', 'infile': '%f',
  140. 'mtime': '%Y%m%d', 'outfile': '%f'}
  141. SETTINGS = {} # for future use
  142. NO_TARGET = ['help', 'version', 'gui', 'toc-only', 'dump-config', 'dump-source', 'targets']
  143. NO_MULTI_INPUT = ['gui','dump-config','dump-source']
  144. CONFIG_KEYWORDS = [
  145. 'target', 'encoding', 'style', 'options', 'preproc','postproc',
  146. 'guicolors']
  147. TARGET_NAMES = {
  148. 'html' : _('HTML page'),
  149. 'xhtml' : _('XHTML page'),
  150. 'sgml' : _('SGML document'),
  151. 'dbk' : _('DocBook document'),
  152. 'tex' : _('LaTeX document'),
  153. 'lout' : _('Lout document'),
  154. 'man' : _('UNIX Manual page'),
  155. 'mgp' : _('MagicPoint presentation'),
  156. 'wiki' : _('Wikipedia page'),
  157. 'gwiki' : _('Google Wiki page'),
  158. 'doku' : _('DokuWiki page'),
  159. 'pmw' : _('PmWiki page'),
  160. 'moin' : _('MoinMoin page'),
  161. 'pm6' : _('PageMaker document'),
  162. 'txt' : _('Plain Text'),
  163. 'art' : _('ASCII Art text'),
  164. 'adoc' : _('AsciiDoc document'),
  165. 'creole' : _('Creole 1.0 document')
  166. }
  167. DEBUG = 0 # do not edit here, please use --debug
  168. VERBOSE = 0 # do not edit here, please use -v, -vv or -vvv
  169. QUIET = 0 # do not edit here, please use --quiet
  170. GUI = 0 # do not edit here, please use --gui
  171. AUTOTOC = 1 # do not edit here, please use --no-toc or %%toc
  172. DFT_TEXT_WIDTH = 72 # do not edit here, please use --width
  173. DFT_SLIDE_WIDTH = 80 # do not edit here, please use --width
  174. DFT_SLIDE_HEIGHT = 25 # do not edit here, please use --height
  175. # ASCII Art config
  176. AA_KEYS = 'corner border side bar1 bar2 level2 level3 level4 level5'.split()
  177. AA_VALUES = '+-|-==-^"' # do not edit here, please use --art-chars
  178. AA = dict(zip(AA_KEYS, AA_VALUES))
  179. AA_COUNT = 0
  180. AA_TITLE = ''
  181. RC_RAW = []
  182. CMDLINE_RAW = []
  183. CONF = {}
  184. BLOCK = None
  185. TITLE = None
  186. regex = {}
  187. TAGS = {}
  188. rules = {}
  189. # Gui globals
  190. askopenfilename = None
  191. showinfo = None
  192. showwarning = None
  193. showerror = None
  194. lang = 'english'
  195. TARGET = ''
  196. STDIN = STDOUT = '-'
  197. MODULEIN = MODULEOUT = '-module-'
  198. ESCCHAR = '\x00'
  199. SEPARATOR = '\x01'
  200. LISTNAMES = {'-':'list', '+':'numlist', ':':'deflist'}
  201. LINEBREAK = {'default':'\n', 'win':'\r\n', 'mac':'\r'}
  202. # Platform specific settings
  203. LB = LINEBREAK.get(sys.platform[:3]) or LINEBREAK['default']
  204. VERSIONSTR = _("%s version %s <%s>")%(my_name,my_version,my_url)
  205. USAGE = '\n'.join([
  206. '',
  207. _("Usage: %s [OPTIONS] [infile.t2t ...]") % my_name,
  208. '',
  209. _(" --targets print a list of all the available targets and exit"),
  210. _(" -t, --target=TYPE set target document type. currently supported:"),
  211. ' %s,' % ', '.join(TARGETS[:9]),
  212. ' %s' % ', '.join(TARGETS[9:]),
  213. _(" -i, --infile=FILE set FILE as the input file name ('-' for STDIN)"),
  214. _(" -o, --outfile=FILE set FILE as the output file name ('-' for STDOUT)"),
  215. _(" --encoding=ENC set target file encoding (utf-8, iso-8859-1, etc)"),
  216. _(" --toc add an automatic Table of Contents to the output"),
  217. _(" --toc-level=N set maximum TOC level (depth) to N"),
  218. _(" --toc-only print the Table of Contents and exit"),
  219. _(" -n, --enum-title enumerate all titles as 1, 1.1, 1.1.1, etc"),
  220. _(" --style=FILE use FILE as the document style (like HTML CSS)"),
  221. _(" --css-sugar insert CSS-friendly tags for HTML/XHTML"),
  222. _(" --css-inside insert CSS file contents inside HTML/XHTML headers"),
  223. _(" -H, --no-headers suppress header and footer from the output"),
  224. _(" --mask-email hide email from spam robots. x@y.z turns <x (a) y z>"),
  225. _(" --slides format output as presentation slides (used by -t art)"),
  226. _(" --width=N set the output's width to N columns (used by -t art)"),
  227. _(" --height=N set the output's height to N rows (used by -t art)"),
  228. _(" -C, --config-file=F read configuration from file F"),
  229. _(" --gui invoke Graphical Tk Interface"),
  230. _(" -q, --quiet quiet mode, suppress all output (except errors)"),
  231. _(" -v, --verbose print informative messages during conversion"),
  232. _(" -h, --help print this help information and exit"),
  233. _(" -V, --version print program version and exit"),
  234. _(" --dump-config print all the configuration found and exit"),
  235. _(" --dump-source print the document source, with includes expanded"),
  236. '',
  237. _("Turn OFF options:"),
  238. " --no-css-inside, --no-css-sugar, --no-dump-config, --no-dump-source,",
  239. " --no-encoding, --no-enum-title, --no-headers, --no-infile,",
  240. " --no-mask-email, --no-outfile, --no-quiet, --no-rc, --no-slides,",
  241. " --no-style, --no-targets, --no-toc, --no-toc-only",
  242. '',
  243. _("Example:"),
  244. " %s -t html --toc %s" % (my_name, _("file.t2t")),
  245. '',
  246. _("By default, converted output is saved to 'infile.<target>'."),
  247. _("Use --outfile to force an output file name."),
  248. _("If input file is '-', reads from STDIN."),
  249. _("If output file is '-', dumps output to STDOUT."),
  250. '',
  251. my_url,
  252. ''
  253. ])
  254. ##############################################################################
  255. # Here is all the target's templates
  256. # You may edit them to fit your needs
  257. # - the %(HEADERn)s strings represent the Header lines
  258. # - the %(STYLE)s string is changed by --style contents
  259. # - the %(ENCODING)s string is changed by --encoding contents
  260. # - if any of the above is empty, the full line is removed
  261. # - use %% to represent a literal %
  262. #
  263. HEADER_TEMPLATE = {
  264. 'art':"""
  265. Fake template to respect the general process.
  266. """,
  267. 'txt': """\
  268. %(HEADER1)s
  269. %(HEADER2)s
  270. %(HEADER3)s
  271. """,
  272. 'sgml': """\
  273. <!doctype linuxdoc system>
  274. <article>
  275. <title>%(HEADER1)s
  276. <author>%(HEADER2)s
  277. <date>%(HEADER3)s
  278. """,
  279. 'html': """\
  280. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  281. <HTML>
  282. <HEAD>
  283. <META NAME="generator" CONTENT="http://txt2tags.org">
  284. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=%(ENCODING)s">
  285. <LINK REL="stylesheet" TYPE="text/css" HREF="%(STYLE)s">
  286. <TITLE>%(HEADER1)s</TITLE>
  287. </HEAD><BODY BGCOLOR="white" TEXT="black">
  288. <CENTER>
  289. <H1>%(HEADER1)s</H1>
  290. <FONT SIZE="4"><I>%(HEADER2)s</I></FONT><BR>
  291. <FONT SIZE="4">%(HEADER3)s</FONT>
  292. </CENTER>
  293. """,
  294. 'htmlcss': """\
  295. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  296. <HTML>
  297. <HEAD>
  298. <META NAME="generator" CONTENT="http://txt2tags.org">
  299. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=%(ENCODING)s">
  300. <LINK REL="stylesheet" TYPE="text/css" HREF="%(STYLE)s">
  301. <TITLE>%(HEADER1)s</TITLE>
  302. </HEAD>
  303. <BODY>
  304. <DIV CLASS="header" ID="header">
  305. <H1>%(HEADER1)s</H1>
  306. <H2>%(HEADER2)s</H2>
  307. <H3>%(HEADER3)s</H3>
  308. </DIV>
  309. """,
  310. 'xhtml': """\
  311. <?xml version="1.0"
  312. encoding="%(ENCODING)s"
  313. ?>
  314. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\
  315. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  316. <html xmlns="http://www.w3.org/1999/xhtml">
  317. <head>
  318. <title>%(HEADER1)s</title>
  319. <meta name="generator" content="http://txt2tags.org" />
  320. <link rel="stylesheet" type="text/css" href="%(STYLE)s" />
  321. </head>
  322. <body bgcolor="white" text="black">
  323. <div align="center">
  324. <h1>%(HEADER1)s</h1>
  325. <h2>%(HEADER2)s</h2>
  326. <h3>%(HEADER3)s</h3>
  327. </div>
  328. """,
  329. 'xhtmlcss': """\
  330. <?xml version="1.0"
  331. encoding="%(ENCODING)s"
  332. ?>
  333. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\
  334. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  335. <html xmlns="http://www.w3.org/1999/xhtml">
  336. <head>
  337. <title>%(HEADER1)s</title>
  338. <meta name="generator" content="http://txt2tags.org" />
  339. <link rel="stylesheet" type="text/css" href="%(STYLE)s" />
  340. </head>
  341. <body>
  342. <div class="header" id="header">
  343. <h1>%(HEADER1)s</h1>
  344. <h2>%(HEADER2)s</h2>
  345. <h3>%(HEADER3)s</h3>
  346. </div>
  347. """,
  348. 'dbk': """\
  349. <?xml version="1.0"
  350. encoding="%(ENCODING)s"
  351. ?>
  352. <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"\
  353. "docbook/dtd/xml/4.5/docbookx.dtd">
  354. <article lang="en">
  355. <articleinfo>
  356. <title>%(HEADER1)s</title>
  357. <authorgroup>
  358. <author><othername>%(HEADER2)s</othername></author>
  359. </authorgroup>
  360. <date>%(HEADER3)s</date>
  361. </articleinfo>
  362. """,
  363. 'man': """\
  364. .TH "%(HEADER1)s" 1 "%(HEADER3)s" "%(HEADER2)s"
  365. """,
  366. # TODO style to <HR>
  367. 'pm6': """\
  368. <PMTags1.0 win><C-COLORTABLE ("Preto" 1 0 0 0)
  369. ><@Normal=
  370. <FONT "Times New Roman"><CCOLOR "Preto"><SIZE 11>
  371. <HORIZONTAL 100><LETTERSPACE 0><CTRACK 127><CSSIZE 70><C+SIZE 58.3>
  372. <C-POSITION 33.3><C+POSITION 33.3><P><CBASELINE 0><CNOBREAK 0><CLEADING -0.05>
  373. <GGRID 0><GLEFT 7.2><GRIGHT 0><GFIRST 0><G+BEFORE 7.2><G+AFTER 0>
  374. <GALIGNMENT "justify"><GMETHOD "proportional"><G& "ENGLISH">
  375. <GPAIRS 12><G%% 120><GKNEXT 0><GKWIDOW 0><GKORPHAN 0><GTABS $>
  376. <GHYPHENATION 2 34 0><GWORDSPACE 75 100 150><GSPACE -5 0 25>
  377. ><@Bullet=<@-PARENT "Normal"><FONT "Abadi MT Condensed Light">
  378. <GLEFT 14.4><G+BEFORE 2.15><G%% 110><GTABS(25.2 l "")>
  379. ><@PreFormat=<@-PARENT "Normal"><FONT "Lucida Console"><SIZE 8><CTRACK 0>
  380. <GLEFT 0><G+BEFORE 0><GALIGNMENT "left"><GWORDSPACE 100 100 100><GSPACE 0 0 0>
  381. ><@Title1=<@-PARENT "Normal"><FONT "Arial"><SIZE 14><B>
  382. <GCONTENTS><GLEFT 0><G+BEFORE 0><GALIGNMENT "left">
  383. ><@Title2=<@-PARENT "Title1"><SIZE 12><G+BEFORE 3.6>
  384. ><@Title3=<@-PARENT "Title1"><SIZE 10><GLEFT 7.2><G+BEFORE 7.2>
  385. ><@Title4=<@-PARENT "Title3">
  386. ><@Title5=<@-PARENT "Title3">
  387. ><@Quote=<@-PARENT "Normal"><SIZE 10><I>>
  388. %(HEADER1)s
  389. %(HEADER2)s
  390. %(HEADER3)s
  391. """,
  392. 'mgp': """\
  393. #!/usr/X11R6/bin/mgp -t 90
  394. %%deffont "normal" xfont "utopia-medium-r", charset "iso8859-1"
  395. %%deffont "normal-i" xfont "utopia-medium-i", charset "iso8859-1"
  396. %%deffont "normal-b" xfont "utopia-bold-r" , charset "iso8859-1"
  397. %%deffont "normal-bi" xfont "utopia-bold-i" , charset "iso8859-1"
  398. %%deffont "mono" xfont "courier-medium-r", charset "iso8859-1"
  399. %%default 1 size 5
  400. %%default 2 size 8, fore "yellow", font "normal-b", center
  401. %%default 3 size 5, fore "white", font "normal", left, prefix " "
  402. %%tab 1 size 4, vgap 30, prefix " ", icon arc "red" 40, leftfill
  403. %%tab 2 prefix " ", icon arc "orange" 40, leftfill
  404. %%tab 3 prefix " ", icon arc "brown" 40, leftfill
  405. %%tab 4 prefix " ", icon arc "darkmagenta" 40, leftfill
  406. %%tab 5 prefix " ", icon arc "magenta" 40, leftfill
  407. %%%%------------------------- end of headers -----------------------------
  408. %%page
  409. %%size 10, center, fore "yellow"
  410. %(HEADER1)s
  411. %%font "normal-i", size 6, fore "white", center
  412. %(HEADER2)s
  413. %%font "mono", size 7, center
  414. %(HEADER3)s
  415. """,
  416. 'moin': """\
  417. '''%(HEADER1)s'''
  418. ''%(HEADER2)s''
  419. %(HEADER3)s
  420. """,
  421. 'gwiki': """\
  422. *%(HEADER1)s*
  423. %(HEADER2)s
  424. _%(HEADER3)s_
  425. """,
  426. 'adoc': """\
  427. = %(HEADER1)s
  428. %(HEADER2)s
  429. %(HEADER3)s
  430. """,
  431. 'doku': """\
  432. ===== %(HEADER1)s =====
  433. **//%(HEADER2)s//**
  434. //%(HEADER3)s//
  435. """,
  436. 'pmw': """\
  437. (:Title %(HEADER1)s:)
  438. (:Description %(HEADER2)s:)
  439. (:Summary %(HEADER3)s:)
  440. """,
  441. 'wiki': """\
  442. '''%(HEADER1)s'''
  443. %(HEADER2)s
  444. ''%(HEADER3)s''
  445. """,
  446. 'tex': \
  447. r"""\documentclass{article}
  448. \usepackage{graphicx}
  449. \usepackage{paralist} %% needed for compact lists
  450. \usepackage[normalem]{ulem} %% needed by strike
  451. \usepackage[urlcolor=blue,colorlinks=true]{hyperref}
  452. \usepackage[%(ENCODING)s]{inputenc} %% char encoding
  453. \usepackage{%(STYLE)s} %% user defined
  454. \title{%(HEADER1)s}
  455. \author{%(HEADER2)s}
  456. \begin{document}
  457. \date{%(HEADER3)s}
  458. \maketitle
  459. \clearpage
  460. """,
  461. 'lout': """\
  462. @SysInclude { doc }
  463. @Document
  464. @InitialFont { Times Base 12p } # Times, Courier, Helvetica, ...
  465. @PageOrientation { Portrait } # Portrait, Landscape
  466. @ColumnNumber { 1 } # Number of columns (2, 3, ...)
  467. @PageHeaders { Simple } # None, Simple, Titles, NoTitles
  468. @InitialLanguage { English } # German, French, Portuguese, ...
  469. @OptimizePages { Yes } # Yes/No smart page break feature
  470. //
  471. @Text @Begin
  472. @Display @Heading { %(HEADER1)s }
  473. @Display @I { %(HEADER2)s }
  474. @Display { %(HEADER3)s }
  475. #@NP # Break page after Headers
  476. """,
  477. 'creole': """\
  478. %(HEADER1)s
  479. %(HEADER2)s
  480. %(HEADER3)s
  481. """
  482. # @SysInclude { tbl } # Tables support
  483. # setup: @MakeContents { Yes } # show TOC
  484. # setup: @SectionGap # break page at each section
  485. }
  486. ##############################################################################
  487. def getTags(config):
  488. "Returns all the known tags for the specified target"
  489. keys = """
  490. title1 numtitle1
  491. title2 numtitle2
  492. title3 numtitle3
  493. title4 numtitle4
  494. title5 numtitle5
  495. title1Open title1Close
  496. title2Open title2Close
  497. title3Open title3Close
  498. title4Open title4Close
  499. title5Open title5Close
  500. blocktitle1Open blocktitle1Close
  501. blocktitle2Open blocktitle2Close
  502. blocktitle3Open blocktitle3Close
  503. paragraphOpen paragraphClose
  504. blockVerbOpen blockVerbClose
  505. blockQuoteOpen blockQuoteClose blockQuoteLine
  506. blockCommentOpen blockCommentClose
  507. fontMonoOpen fontMonoClose
  508. fontBoldOpen fontBoldClose
  509. fontItalicOpen fontItalicClose
  510. fontUnderlineOpen fontUnderlineClose
  511. fontStrikeOpen fontStrikeClose
  512. listOpen listClose
  513. listOpenCompact listCloseCompact
  514. listItemOpen listItemClose listItemLine
  515. numlistOpen numlistClose
  516. numlistOpenCompact numlistCloseCompact
  517. numlistItemOpen numlistItemClose numlistItemLine
  518. deflistOpen deflistClose
  519. deflistOpenCompact deflistCloseCompact
  520. deflistItem1Open deflistItem1Close
  521. deflistItem2Open deflistItem2Close deflistItem2LinePrefix
  522. bar1 bar2
  523. url urlMark
  524. email emailMark
  525. img imgAlignLeft imgAlignRight imgAlignCenter
  526. _imgAlignLeft _imgAlignRight _imgAlignCenter
  527. tableOpen tableClose
  528. _tableBorder _tableAlignLeft _tableAlignCenter
  529. tableRowOpen tableRowClose tableRowSep
  530. tableTitleRowOpen tableTitleRowClose
  531. tableCellOpen tableCellClose tableCellSep
  532. tableTitleCellOpen tableTitleCellClose tableTitleCellSep
  533. _tableColAlignLeft _tableColAlignRight _tableColAlignCenter
  534. _tableCellAlignLeft _tableCellAlignRight _tableCellAlignCenter
  535. _tableCellColSpan tableColAlignSep
  536. _tableCellMulticolOpen
  537. _tableCellMulticolClose
  538. bodyOpen bodyClose
  539. cssOpen cssClose
  540. tocOpen tocClose TOC
  541. anchor
  542. comment
  543. pageBreak
  544. EOD
  545. """.split()
  546. # TIP: \a represents the current text inside the mark
  547. # TIP: ~A~, ~B~ and ~C~ are expanded to other tags parts
  548. alltags = {
  549. 'art': {
  550. 'title1' : '\a' ,
  551. 'title2' : '\a' ,
  552. 'title3' : '\a' ,
  553. 'title4' : '\a' ,
  554. 'title5' : '\a' ,
  555. 'blockQuoteLine' : '\t' ,
  556. 'listItemOpen' : '- ' ,
  557. 'numlistItemOpen' : '\a. ' ,
  558. 'bar1' : aa_line(AA['bar1'], config['width']),
  559. 'bar2' : aa_line(AA['bar2'], config['width']),
  560. 'url' : '\a' ,
  561. 'urlMark' : '\a (\a)' ,
  562. 'email' : '\a' ,
  563. 'emailMark' : '\a (\a)' ,
  564. 'img' : '[\a]' ,
  565. },
  566. 'txt': {
  567. 'title1' : ' \a' ,
  568. 'title2' : '\t\a' ,
  569. 'title3' : '\t\t\a' ,
  570. 'title4' : '\t\t\t\a' ,
  571. 'title5' : '\t\t\t\t\a',
  572. 'blockQuoteLine' : '\t' ,
  573. 'listItemOpen' : '- ' ,
  574. 'numlistItemOpen' : '\a. ' ,
  575. 'bar1' : '\a' ,
  576. 'url' : '\a' ,
  577. 'urlMark' : '\a (\a)' ,
  578. 'email' : '\a' ,
  579. 'emailMark' : '\a (\a)' ,
  580. 'img' : '[\a]' ,
  581. },
  582. 'html': {
  583. 'paragraphOpen' : '<P>' ,
  584. 'paragraphClose' : '</P>' ,
  585. 'title1' : '~A~<H1>\a</H1>' ,
  586. 'title2' : '~A~<H2>\a</H2>' ,
  587. 'title3' : '~A~<H3>\a</H3>' ,
  588. 'title4' : '~A~<H4>\a</H4>' ,
  589. 'title5' : '~A~<H5>\a</H5>' ,
  590. 'anchor' : '<A NAME="\a"></A>\n',
  591. 'blockVerbOpen' : '<PRE>' ,
  592. 'blockVerbClose' : '</PRE>' ,
  593. 'blockQuoteOpen' : '<BLOCKQUOTE>' ,
  594. 'blockQuoteClose' : '</BLOCKQUOTE>' ,
  595. 'fontMonoOpen' : '<CODE>' ,
  596. 'fontMonoClose' : '</CODE>' ,
  597. 'fontBoldOpen' : '<B>' ,
  598. 'fontBoldClose' : '</B>' ,
  599. 'fontItalicOpen' : '<I>' ,
  600. 'fontItalicClose' : '</I>' ,
  601. 'fontUnderlineOpen' : '<U>' ,
  602. 'fontUnderlineClose' : '</U>' ,
  603. 'fontStrikeOpen' : '<S>' ,
  604. 'fontStrikeClose' : '</S>' ,
  605. 'listOpen' : '<UL>' ,
  606. 'listClose' : '</UL>' ,
  607. 'listItemOpen' : '<LI>' ,
  608. 'numlistOpen' : '<OL>' ,
  609. 'numlistClose' : '</OL>' ,
  610. 'numlistItemOpen' : '<LI>' ,
  611. 'deflistOpen' : '<DL>' ,
  612. 'deflistClose' : '</DL>' ,
  613. 'deflistItem1Open' : '<DT>' ,
  614. 'deflistItem1Close' : '</DT>' ,
  615. 'deflistItem2Open' : '<DD>' ,
  616. 'bar1' : '<HR NOSHADE SIZE=1>' ,
  617. 'bar2' : '<HR NOSHADE SIZE=5>' ,
  618. 'url' : '<A HREF="\a">\a</A>' ,
  619. 'urlMark' : '<A HREF="\a">\a</A>' ,
  620. 'email' : '<A HREF="mailto:\a">\a</A>' ,
  621. 'emailMark' : '<A HREF="mailto:\a">\a</A>' ,
  622. 'img' : '<IMG~A~ SRC="\a" BORDER="0" ALT="">',
  623. '_imgAlignLeft' : ' ALIGN="left"' ,
  624. '_imgAlignCenter' : ' ALIGN="middle"',
  625. '_imgAlignRight' : ' ALIGN="right"' ,
  626. 'tableOpen' : '<TABLE~A~~B~ CELLPADDING="4">',
  627. 'tableClose' : '</TABLE>' ,
  628. 'tableRowOpen' : '<TR>' ,
  629. 'tableRowClose' : '</TR>' ,
  630. 'tableCellOpen' : '<TD~A~~S~>' ,
  631. 'tableCellClose' : '</TD>' ,
  632. 'tableTitleCellOpen' : '<TH~S~>' ,
  633. 'tableTitleCellClose' : '</TH>' ,
  634. '_tableBorder' : ' BORDER="1"' ,
  635. '_tableAlignCenter' : ' ALIGN="center"',
  636. '_tableCellAlignRight' : ' ALIGN="right"' ,
  637. '_tableCellAlignCenter': ' ALIGN="center"',
  638. '_tableCellColSpan' : ' COLSPAN="\a"' ,
  639. 'cssOpen' : '<STYLE TYPE="text/css">',
  640. 'cssClose' : '</STYLE>' ,
  641. 'comment' : '<!-- \a -->' ,
  642. 'EOD' : '</BODY></HTML>'
  643. },
  644. #TIP xhtml inherits all HTML definitions (lowercased)
  645. #TIP http://www.w3.org/TR/xhtml1/#guidelines
  646. #TIP http://www.htmlref.com/samples/Chapt17/17_08.htm
  647. 'xhtml': {
  648. 'listItemClose' : '</li>' ,
  649. 'numlistItemClose' : '</li>' ,
  650. 'deflistItem2Close' : '</dd>' ,
  651. 'bar1' : '<hr class="light" />',
  652. 'bar2' : '<hr class="heavy" />',
  653. 'anchor' : '<a id="\a" name="\a"></a>\n',
  654. 'img' : '<img~A~ src="\a" border="0" alt=""/>',
  655. },
  656. 'sgml': {
  657. 'paragraphOpen' : '<p>' ,
  658. 'title1' : '<sect>\a~A~<p>' ,
  659. 'title2' : '<sect1>\a~A~<p>' ,
  660. 'title3' : '<sect2>\a~A~<p>' ,
  661. 'title4' : '<sect3>\a~A~<p>' ,
  662. 'title5' : '<sect4>\a~A~<p>' ,
  663. 'anchor' : '<label id="\a">' ,
  664. 'blockVerbOpen' : '<tscreen><verb>' ,
  665. 'blockVerbClose' : '</verb></tscreen>' ,
  666. 'blockQuoteOpen' : '<quote>' ,
  667. 'blockQuoteClose' : '</quote>' ,
  668. 'fontMonoOpen' : '<tt>' ,
  669. 'fontMonoClose' : '</tt>' ,
  670. 'fontBoldOpen' : '<bf>' ,
  671. 'fontBoldClose' : '</bf>' ,
  672. 'fontItalicOpen' : '<em>' ,
  673. 'fontItalicClose' : '</em>' ,
  674. 'fontUnderlineOpen' : '<bf><em>' ,
  675. 'fontUnderlineClose' : '</em></bf>' ,
  676. 'listOpen' : '<itemize>' ,
  677. 'listClose' : '</itemize>' ,
  678. 'listItemOpen' : '<item>' ,
  679. 'numlistOpen' : '<enum>' ,
  680. 'numlistClose' : '</enum>' ,
  681. 'numlistItemOpen' : '<item>' ,
  682. 'deflistOpen' : '<descrip>' ,
  683. 'deflistClose' : '</descrip>' ,
  684. 'deflistItem1Open' : '<tag>' ,
  685. 'deflistItem1Close' : '</tag>' ,
  686. 'bar1' : '<!-- \a -->' ,
  687. 'url' : '<htmlurl url="\a" name="\a">' ,
  688. 'urlMark' : '<htmlurl url="\a" name="\a">' ,
  689. 'email' : '<htmlurl url="mailto:\a" name="\a">' ,
  690. 'emailMark' : '<htmlurl url="mailto:\a" name="\a">' ,
  691. 'img' : '<figure><ph vspace=""><img src="\a"></figure>',
  692. 'tableOpen' : '<table><tabular ca="~C~">' ,
  693. 'tableClose' : '</tabular></table>' ,
  694. 'tableRowSep' : '<rowsep>' ,
  695. 'tableCellSep' : '<colsep>' ,
  696. '_tableColAlignLeft' : 'l' ,
  697. '_tableColAlignRight' : 'r' ,
  698. '_tableColAlignCenter' : 'c' ,
  699. 'comment' : '<!-- \a -->' ,
  700. 'TOC' : '<toc>' ,
  701. 'EOD' : '</article>'
  702. },
  703. 'dbk': {
  704. 'paragraphOpen' : '<para>' ,
  705. 'paragraphClose' : '</para>' ,
  706. 'title1Open' : '~A~<sect1><title>\a</title>' ,
  707. 'title1Close' : '</sect1>' ,
  708. 'title2Open' : '~A~ <sect2><title>\a</title>' ,
  709. 'title2Close' : ' </sect2>' ,
  710. 'title3Open' : '~A~ <sect3><title>\a</title>' ,
  711. 'title3Close' : ' </sect3>' ,
  712. 'title4Open' : '~A~ <sect4><title>\a</title>' ,
  713. 'title4Close' : ' </sect4>' ,
  714. 'title5Open' : '~A~ <sect5><title>\a</title>',
  715. 'title5Close' : ' </sect5>' ,
  716. 'anchor' : '<anchor id="\a"/>\n' ,
  717. 'blockVerbOpen' : '<programlisting>' ,
  718. 'blockVerbClose' : '</programlisting>' ,
  719. 'blockQuoteOpen' : '<blockquote><para>' ,
  720. 'blockQuoteClose' : '</para></blockquote>' ,
  721. 'fontMonoOpen' : '<code>' ,
  722. 'fontMonoClose' : '</code>' ,
  723. 'fontBoldOpen' : '<emphasis role="bold">' ,
  724. 'fontBoldClose' : '</emphasis>' ,
  725. 'fontItalicOpen' : '<emphasis>' ,
  726. 'fontItalicClose' : '</emphasis>' ,
  727. 'fontUnderlineOpen' : '<emphasis role="underline">' ,
  728. 'fontUnderlineClose' : '</emphasis>' ,
  729. # 'fontStrikeOpen' : '<emphasis role="strikethrough">' , # Don't know
  730. # 'fontStrikeClose' : '</emphasis>' ,
  731. 'listOpen' : '<itemizedlist>' ,
  732. 'listClose' : '</itemizedlist>' ,
  733. 'listItemOpen' : '<listitem><para>' ,
  734. 'listItemClose' : '</para></listitem>' ,
  735. 'numlistOpen' : '<orderedlist numeration="arabic">' ,
  736. 'numlistClose' : '</orderedlist>' ,
  737. 'numlistItemOpen' : '<listitem><para>' ,
  738. 'numlistItemClose' : '</para></listitem>' ,
  739. 'deflistOpen' : '<variablelist>' ,
  740. 'deflistClose' : '</variablelist>' ,
  741. 'deflistItem1Open' : '<varlistentry><term>' ,
  742. 'deflistItem1Close' : '</term>' ,
  743. 'deflistItem2Open' : '<listitem><para>' ,
  744. 'deflistItem2Close' : '</para></listitem></varlistentry>' ,
  745. # 'bar1' : '<>' , # Don't know
  746. # 'bar2' : '<>' , # Don't know
  747. 'url' : '<ulink url="\a">\a</ulink>' ,
  748. 'urlMark' : '<ulink url="\a">\a</ulink>' ,
  749. 'email' : '<email>\a</email>' ,
  750. 'emailMark' : '<email>\a</email>' ,
  751. 'img' : '<mediaobject><imageobject><imagedata fileref="\a"/></imageobject></mediaobject>',
  752. # '_imgAlignLeft' : '' , # Don't know
  753. # '_imgAlignCenter' : '' , # Don't know
  754. # '_imgAlignRight' : '' , # Don't know
  755. # 'tableOpen' : '<informaltable><tgroup cols=""><tbody>', # Don't work, need to know number of cols
  756. # 'tableClose' : '</tbody></tgroup></informaltable>' ,
  757. # 'tableRowOpen' : '<row>' ,
  758. # 'tableRowClose' : '</row>' ,
  759. # 'tableCellOpen' : '<entry>' ,
  760. # 'tableCellClose' : '</entry>' ,
  761. # 'tableTitleRowOpen' : '<thead>' ,
  762. # 'tableTitleRowClose' : '</thead>' ,
  763. # '_tableBorder' : ' frame="all"' ,
  764. # '_tableAlignCenter' : ' align="center"' ,
  765. # '_tableCellAlignRight' : ' align="right"' ,
  766. # '_tableCellAlignCenter': ' align="center"' ,
  767. # '_tableCellColSpan' : ' COLSPAN="\a"' ,
  768. 'TOC' : '<index/>' ,
  769. 'comment' : '<!-- \a -->' ,
  770. 'EOD' : '</article>'
  771. },
  772. 'tex': {
  773. 'title1' : '~A~\section*{\a}' ,
  774. 'title2' : '~A~\\subsection*{\a}' ,
  775. 'title3' : '~A~\\subsubsection*{\a}',
  776. # title 4/5: DIRTY: para+BF+\\+\n
  777. 'title4' : '~A~\\paragraph{}\\textbf{\a}\\\\\n',
  778. 'title5' : '~A~\\paragraph{}\\textbf{\a}\\\\\n',
  779. 'numtitle1' : '\n~A~\section{\a}' ,
  780. 'numtitle2' : '~A~\\subsection{\a}' ,
  781. 'numtitle3' : '~A~\\subsubsection{\a}' ,
  782. 'anchor' : '\\hypertarget{\a}{}\n' ,
  783. 'blockVerbOpen' : '\\begin{verbatim}' ,
  784. 'blockVerbClose' : '\\end{verbatim}' ,
  785. 'blockQuoteOpen' : '\\begin{quotation}' ,
  786. 'blockQuoteClose' : '\\end{quotation}' ,
  787. 'fontMonoOpen' : '\\texttt{' ,
  788. 'fontMonoClose' : '}' ,
  789. 'fontBoldOpen' : '\\textbf{' ,
  790. 'fontBoldClose' : '}' ,
  791. 'fontItalicOpen' : '\\textit{' ,
  792. 'fontItalicClose' : '}' ,
  793. 'fontUnderlineOpen' : '\\underline{' ,
  794. 'fontUnderlineClose' : '}' ,
  795. 'fontStrikeOpen' : '\\sout{' ,
  796. 'fontStrikeClose' : '}' ,
  797. 'listOpen' : '\\begin{itemize}' ,
  798. 'listClose' : '\\end{itemize}' ,
  799. 'listOpenCompact' : '\\begin{compactitem}',
  800. 'listCloseCompact' : '\\end{compactitem}' ,
  801. 'listItemOpen' : '\\item ' ,
  802. 'numlistOpen' : '\\begin{enumerate}' ,
  803. 'numlistClose' : '\\end{enumerate}' ,
  804. 'numlistOpenCompact' : '\\begin{compactenum}',
  805. 'numlistCloseCompact' : '\\end{compactenum}' ,
  806. 'numlistItemOpen' : '\\item ' ,
  807. 'deflistOpen' : '\\begin{description}',
  808. 'deflistClose' : '\\end{description}' ,
  809. 'deflistOpenCompact' : '\\begin{compactdesc}',
  810. 'deflistCloseCompact' : '\\end{compactdesc}' ,
  811. 'deflistItem1Open' : '\\item[' ,
  812. 'deflistItem1Close' : ']' ,
  813. 'bar1' : '\\hrulefill{}' ,
  814. 'bar2' : '\\rule{\linewidth}{1mm}',
  815. 'url' : '\\htmladdnormallink{\a}{\a}',
  816. 'urlMark' : '\\htmladdnormallink{\a}{\a}',
  817. 'email' : '\\htmladdnormallink{\a}{mailto:\a}',
  818. 'emailMark' : '\\htmladdnormallink{\a}{mailto:\a}',
  819. 'img' : '\\includegraphics{\a}',
  820. 'tableOpen' : '\\begin{center}\\begin{tabular}{|~C~|}',
  821. 'tableClose' : '\\end{tabular}\\end{center}',
  822. 'tableRowOpen' : '\\hline ' ,
  823. 'tableRowClose' : ' \\\\' ,
  824. 'tableCellSep' : ' & ' ,
  825. '_tableColAlignLeft' : 'l' ,
  826. '_tableColAlignRight' : 'r' ,
  827. '_tableColAlignCenter' : 'c' ,
  828. '_tableCellAlignLeft' : 'l' ,
  829. '_tableCellAlignRight' : 'r' ,
  830. '_tableCellAlignCenter': 'c' ,
  831. '_tableCellColSpan' : '\a' ,
  832. '_tableCellMulticolOpen' : '\\multicolumn{\a}{|~C~|}{',
  833. '_tableCellMulticolClose' : '}',
  834. 'tableColAlignSep' : '|' ,
  835. 'comment' : '% \a' ,
  836. 'TOC' : '\\tableofcontents',
  837. 'pageBreak' : '\\clearpage',
  838. 'EOD' : '\\end{document}'
  839. },
  840. 'lout': {
  841. 'paragraphOpen' : '@LP' ,
  842. 'blockTitle1Open' : '@BeginSections' ,
  843. 'blockTitle1Close' : '@EndSections' ,
  844. 'blockTitle2Open' : ' @BeginSubSections' ,
  845. 'blockTitle2Close' : ' @EndSubSections' ,
  846. 'blockTitle3Open' : ' @BeginSubSubSections' ,
  847. 'blockTitle3Close' : ' @EndSubSubSections' ,
  848. 'title1Open' : '~A~@Section @Title { \a } @Begin',
  849. 'title1Close' : '@End @Section' ,
  850. 'title2Open' : '~A~ @SubSection @Title { \a } @Begin',
  851. 'title2Close' : ' @End @SubSection' ,
  852. 'title3Open' : '~A~ @SubSubSection @Title { \a } @Begin',
  853. 'title3Close' : ' @End @SubSubSection' ,
  854. 'title4Open' : '~A~@LP @LeftDisplay @B { \a }',
  855. 'title5Open' : '~A~@LP @LeftDisplay @B { \a }',
  856. 'anchor' : '@Tag { \a }\n' ,
  857. 'blockVerbOpen' : '@LP @ID @F @RawVerbatim @Begin',
  858. 'blockVerbClose' : '@End @RawVerbatim' ,
  859. 'blockQuoteOpen' : '@QD {' ,
  860. 'blockQuoteClose' : '}' ,
  861. # enclosed inside {} to deal with joined**words**
  862. 'fontMonoOpen' : '{@F {' ,
  863. 'fontMonoClose' : '}}' ,
  864. 'fontBoldOpen' : '{@B {' ,
  865. 'fontBoldClose' : '}}' ,
  866. 'fontItalicOpen' : '{@II {' ,
  867. 'fontItalicClose' : '}}' ,
  868. 'fontUnderlineOpen' : '{@Underline{' ,
  869. 'fontUnderlineClose' : '}}' ,
  870. # the full form is more readable, but could be BL EL LI NL TL DTI
  871. 'listOpen' : '@BulletList' ,
  872. 'listClose' : '@EndList' ,
  873. 'listItemOpen' : '@ListItem{' ,
  874. 'listItemClose' : '}' ,
  875. 'numlistOpen' : '@NumberedList' ,
  876. 'numlistClose' : '@EndList' ,
  877. 'numlistItemOpen' : '@ListItem{' ,
  878. 'numlistItemClose' : '}' ,
  879. 'deflistOpen' : '@TaggedList' ,
  880. 'deflistClose' : '@EndList' ,
  881. 'deflistItem1Open' : '@DropTagItem {' ,
  882. 'deflistItem1Close' : '}' ,
  883. 'deflistItem2Open' : '{' ,
  884. 'deflistItem2Close' : '}' ,
  885. 'bar1' : '@DP @FullWidthRule' ,
  886. 'url' : '{blue @Colour { \a }}' ,
  887. 'urlMark' : '\a ({blue @Colour { \a }})' ,
  888. 'email' : '{blue @Colour { \a }}' ,
  889. 'emailMark' : '\a ({blue Colour{ \a }})' ,
  890. 'img' : '~A~@IncludeGraphic { \a }' , # eps only!
  891. '_imgAlignLeft' : '@LeftDisplay ' ,
  892. '_imgAlignRight' : '@RightDisplay ' ,
  893. '_imgAlignCenter' : '@CentredDisplay ' ,
  894. # lout tables are *way* complicated, no support for now
  895. #'tableOpen' : '~A~@Tbl~B~\naformat{ @Cell A | @Cell B } {',
  896. #'tableClose' : '}' ,
  897. #'tableRowOpen' : '@Rowa\n' ,
  898. #'tableTitleRowOpen' : '@HeaderRowa' ,
  899. #'tableCenterAlign' : '@CentredDisplay ' ,
  900. #'tableCellOpen' : '\a {' , # A, B, ...
  901. #'tableCellClose' : '}' ,
  902. #'_tableBorder' : '\nrule {yes}' ,
  903. 'comment' : '# \a' ,
  904. # @MakeContents must be on the config file
  905. 'TOC' : '@DP @ContentsGoesHere @DP',
  906. 'pageBreak' : '@NP' ,
  907. 'EOD' : '@End @Text'
  908. },
  909. # http://moinmo.in/SyntaxReference
  910. 'moin': {
  911. 'title1' : '= \a =' ,
  912. 'title2' : '== \a ==' ,
  913. 'title3' : '=== \a ===' ,
  914. 'title4' : '==== \a ====' ,
  915. 'title5' : '===== \a =====',
  916. 'blockVerbOpen' : '{{{' ,
  917. 'blockVerbClose' : '}}}' ,
  918. 'blockQuoteLine' : ' ' ,
  919. 'fontMonoOpen' : '{{{' ,
  920. 'fontMonoClose' : '}}}' ,
  921. 'fontBoldOpen' : "'''" ,
  922. 'fontBoldClose' : "'''" ,
  923. 'fontItalicOpen' : "''" ,
  924. 'fontItalicClose' : "''" ,
  925. 'fontUnderlineOpen' : '__' ,
  926. 'fontUnderlineClose' : '__' ,
  927. 'fontStrikeOpen' : '--(' ,
  928. 'fontStrikeClose' : ')--' ,
  929. 'listItemOpen' : ' * ' ,
  930. 'numlistItemOpen' : ' \a. ' ,
  931. 'deflistItem1Open' : ' ' ,
  932. 'deflistItem1Close' : '::' ,
  933. 'deflistItem2LinePrefix': ' :: ' ,
  934. 'bar1' : '----' ,
  935. 'bar2' : '--------' ,
  936. 'url' : '[\a]' ,
  937. 'urlMark' : '[\a \a]' ,
  938. 'email' : '[\a]' ,
  939. 'emailMark' : '[\a \a]' ,
  940. 'img' : '[\a]' ,
  941. 'tableRowOpen' : '||' ,
  942. 'tableCellOpen' : '~A~' ,
  943. 'tableCellClose' : '||' ,
  944. 'tableTitleCellClose' : '||' ,
  945. '_tableCellAlignRight' : '<)>' ,
  946. '_tableCellAlignCenter' : '<:>' ,
  947. 'comment' : '/* \a */' ,
  948. 'TOC' : '[[TableOfContents]]'
  949. },
  950. # http://code.google.com/p/support/wiki/WikiSyntax
  951. 'gwiki': {
  952. 'title1' : '= \a =' ,
  953. 'title2' : '== \a ==' ,
  954. 'title3' : '=== \a ===' ,
  955. 'title4' : '==== \a ====' ,
  956. 'title5' : '===== \a =====',
  957. 'blockVerbOpen' : '{{{' ,
  958. 'blockVerbClose' : '}}}' ,
  959. 'blockQuoteLine' : ' ' ,
  960. 'fontMonoOpen' : '{{{' ,
  961. 'fontMonoClose' : '}}}' ,
  962. 'fontBoldOpen' : '*' ,
  963. 'fontBoldClose' : '*' ,
  964. 'fontItalicOpen' : '_' , # underline == italic
  965. 'fontItalicClose' : '_' ,
  966. 'fontStrikeOpen' : '~~' ,
  967. 'fontStrikeClose' : '~~' ,
  968. 'listItemOpen' : ' * ' ,
  969. 'numlistItemOpen' : ' # ' ,
  970. 'url' : '\a' ,
  971. 'urlMark' : '[\a \a]' ,
  972. 'email' : 'mailto:\a' ,
  973. 'emailMark' : '[mailto:\a \a]',
  974. 'img' : '[\a]' ,
  975. 'tableRowOpen' : '|| ' ,
  976. 'tableRowClose' : ' ||' ,
  977. 'tableCellSep' : ' || ' ,
  978. },
  979. # http://powerman.name/doc/asciidoc
  980. 'adoc': {
  981. 'title1' : '== \a' ,
  982. 'title2' : '=== \a' ,
  983. 'title3' : '==== \a' ,
  984. 'title4' : '===== \a' ,
  985. 'title5' : '===== \a' ,
  986. 'blockVerbOpen' : '----' ,
  987. 'blockVerbClose' : '----' ,
  988. 'fontMonoOpen' : '+' ,
  989. 'fontMonoClose' : '+' ,
  990. 'fontBoldOpen' : '*' ,
  991. 'fontBoldClose' : '*' ,
  992. 'fontItalicOpen' : '_' ,
  993. 'fontItalicClose' : '_' ,
  994. 'listItemOpen' : '- ' ,
  995. 'listItemLine' : '\t' ,
  996. 'numlistItemOpen' : '. ' ,
  997. 'url' : '\a' ,
  998. 'urlMark' : '\a[\a]' ,
  999. 'email' : 'mailto:\a' ,
  1000. 'emailMark' : 'mailto:\a[\a]' ,
  1001. 'img' : 'image::\a[]' ,
  1002. },
  1003. # http://wiki.splitbrain.org/wiki:syntax
  1004. # Hint: <br> is \\ $
  1005. # Hint: You can add footnotes ((This is a footnote))
  1006. 'doku': {
  1007. 'title1' : '===== \a =====',
  1008. 'title2' : '==== \a ====' ,
  1009. 'title3' : '=== \a ===' ,
  1010. 'title4' : '== \a ==' ,
  1011. 'title5' : '= \a =' ,
  1012. # DokuWiki uses ' ' identation to mark verb blocks (see indentverbblock)
  1013. 'blockQuoteLine' : '>' ,
  1014. 'fontMonoOpen' : "''" ,
  1015. 'fontMonoClose' : "''" ,
  1016. 'fontBoldOpen' : "**" ,
  1017. 'fontBoldClose' : "**" ,
  1018. 'fontItalicOpen' : "//" ,
  1019. 'fontItalicClose' : "//" ,
  1020. 'fontUnderlineOpen' : "__" ,
  1021. 'fontUnderlineClose' : "__" ,
  1022. 'fontStrikeOpen' : '<del>' ,
  1023. 'fontStrikeClose' : '</del>' ,
  1024. 'listItemOpen' : ' * ' ,
  1025. 'numlistItemOpen' : ' - ' ,
  1026. 'bar1' : '----' ,
  1027. 'url' : '[[\a]]' ,
  1028. 'urlMark' : '[[\a|\a]]' ,
  1029. 'email' : '[[\a]]' ,
  1030. 'emailMark' : '[[\a|\a]]' ,
  1031. 'img' : '{{\a}}' ,
  1032. 'imgAlignLeft' : '{{\a }}' ,
  1033. 'imgAlignRight' : '{{ \a}}' ,
  1034. 'imgAlignCenter' : '{{ \a }}' ,
  1035. 'tableTitleRowOpen' : '^ ' ,
  1036. 'tableTitleRowClose' : ' ^' ,
  1037. 'tableTitleCellSep' : ' ^ ' ,
  1038. 'tableRowOpen' : '| ' ,
  1039. 'tableRowClose' : ' |' ,
  1040. 'tableCellSep' : ' | ' ,
  1041. # DokuWiki has no attributes. The content must be aligned!
  1042. # '_tableCellAlignRight' : '<)>' , # ??
  1043. # '_tableCellAlignCenter': '<:>' , # ??
  1044. # DokuWiki colspan is the same as txt2tags' with multiple |||
  1045. # 'comment' : '## \a' , # ??
  1046. # TOC is automatic
  1047. },
  1048. # http://www.pmwiki.org/wiki/PmWiki/TextFormattingRules
  1049. 'pmw': {
  1050. 'title1' : '~A~! \a ' ,
  1051. 'title2' : '~A~!! \a ' ,
  1052. 'title3' : '~A~!!! \a ' ,
  1053. 'title4' : '~A~!!!! \a ' ,
  1054. 'title5' : '~A~!!!!! \a ' ,
  1055. 'blockQuoteOpen' : '->' ,
  1056. 'blockQuoteClose' : '\n' ,
  1057. # In-text font
  1058. 'fontLargeOpen' : "[+" ,
  1059. 'fontLargeClose' : "+]" ,
  1060. 'fontLargerOpen' : "[++" ,
  1061. 'fontLargerClose' : "++]" ,
  1062. 'fontSmallOpen' : "[-" ,
  1063. 'fontSmallClose' : "-]" ,
  1064. 'fontLargerOpen' : "[--" ,
  1065. 'fontLargerClose' : "--]" ,
  1066. 'fontMonoOpen' : "@@" ,
  1067. 'fontMonoClose' : "@@" ,
  1068. 'fontBoldOpen' : "'''" ,
  1069. 'fontBoldClose' : "'''" ,
  1070. 'fontItalicOpen' : "''" ,
  1071. 'fontItalicClose' : "''" ,
  1072. 'fontUnderlineOpen' : "{+" ,
  1073. 'fontUnderlineClose' : "+}" ,
  1074. 'fontStrikeOpen' : '{-' ,
  1075. 'fontStrikeClose' : '-}' ,
  1076. # Lists
  1077. 'listItemLine' : '*' ,
  1078. 'numlistItemLine' : '#' ,
  1079. 'deflistItem1Open' : ': ' ,
  1080. 'deflistItem1Close' : ':' ,
  1081. 'deflistItem2LineOpen' : '::' ,
  1082. 'deflistItem2LineClose' : ':' ,
  1083. # Verbatim block
  1084. 'blockVerbOpen' : '[@' ,
  1085. 'blockVerbClose' : '@]' ,
  1086. 'bar1' : '----' ,
  1087. # URL, email and anchor
  1088. 'url' : '\a' ,
  1089. 'urlMark' : '[[\a -> \a]]' ,
  1090. 'email' : '\a' ,
  1091. 'emailMark' : '[[\a -> mailto:\a]]',
  1092. 'anchor' : '[[#\a]]\n' ,
  1093. # Image markup
  1094. 'img' : '\a' ,
  1095. #'imgAlignLeft' : '{{\a }}' ,
  1096. #'imgAlignRight' : '{{ \a}}' ,
  1097. #'imgAlignCenter' : '{{ \a }}' ,
  1098. # Table attributes
  1099. 'tableTitleRowOpen' : '||! ' ,
  1100. 'tableTitleRowClose' : '||' ,
  1101. 'tableTitleCellSep' : ' ||!' ,
  1102. 'tableRowOpen' : '||' ,
  1103. 'tableRowClose' : '||' ,
  1104. 'tableCellSep' : ' ||' ,
  1105. },
  1106. # http://en.wikipedia.org/wiki/Help:Editing
  1107. 'wiki': {
  1108. 'title1' : '== \a ==' ,
  1109. 'title2' : '=== \a ===' ,
  1110. 'title3' : '==== \a ====' ,
  1111. 'title4' : '===== \a =====' ,
  1112. 'title5' : '====== \a ======',
  1113. 'blockVerbOpen' : '<pre>' ,
  1114. 'blockVerbClose' : '</pre>' ,
  1115. 'blockQuoteOpen' : '<blockquote>' ,
  1116. 'blockQuoteClose' : '</blockquote>' ,
  1117. 'fontMonoOpen' : '<tt>' ,
  1118. 'fontMonoClose' : '</tt>' ,
  1119. 'fontBoldOpen' : "'''" ,
  1120. 'fontBoldClose' : "'''" ,
  1121. 'fontItalicOpen' : "''" ,
  1122. 'fontItalicClose' : "''" ,
  1123. 'fontUnderlineOpen' : '<u>' ,
  1124. 'fontUnderlineClose' : '</u>' ,
  1125. 'fontStrikeOpen' : '<s>' ,
  1126. 'fontStrikeClose' : '</s>' ,
  1127. #XXX Mixed lists not working: *#* list inside numlist inside list
  1128. 'listItemLine' : '*' ,
  1129. 'numlistItemLine' : '#' ,
  1130. 'deflistItem1Open' : '; ' ,
  1131. 'deflistItem2LinePrefix': ': ' ,
  1132. 'bar1' : '----' ,
  1133. 'url' : '[\a]' ,
  1134. 'urlMark' : '[\a \a]' ,
  1135. 'email' : 'mailto:\a' ,
  1136. 'emailMark' : '[mailto:\a \a]' ,
  1137. # [[Image:foo.png|right|Optional alt/caption text]] (right, left, center, none)
  1138. 'img' : '[[Image:\a~A~]]' ,
  1139. '_imgAlignLeft' : '|left' ,
  1140. '_imgAlignCenter' : '|center' ,
  1141. '_imgAlignRight' : '|right' ,
  1142. # {| border="1" cellspacing="0" cellpadding="4" align="center"
  1143. 'tableOpen' : '{|~A~~B~ cellpadding="4"',
  1144. 'tableClose' : '|}' ,
  1145. 'tableRowOpen' : '|-\n| ' ,
  1146. 'tableTitleRowOpen' : '|-\n! ' ,
  1147. 'tableCellSep' : ' || ' ,
  1148. 'tab…

Large files files are truncated, but you can click here to view the full file