annotate MoinMoin/formatter/text_docbook.py @ 3189:c13eca15e247

Completely reworked table support, including: - both html and wiki markup for attributes - horizontal alignment - vertical alignment - cell spanning multiple columns - cell spanning multiple rows - column widths in percent (not displayed by yelp)
author Mikko Virkkil? <mvirkkil@cc.hut.fi>
date Wed, 05 Mar 2008 01:39:04 +0100
parents fd905ed64dff
children a8d2fdac4662
rev   line source
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
1 # -*- coding: utf-8 -*-
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
2 """
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
3 MoinMoin - DocBook Formatter
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
4
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
5 @copyright: 2005,2008 by Mikko Virkkilä <mvirkkil@cc.hut.fi>
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
6 @copyright: 2005 by MoinMoin:AlexanderSchremmer (small modifications)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
7 @copyright: 2005 by MoinMoin:Petr Pytelka <pyta@lightcomp.com> (small modifications)
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
8
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
9 @license: GNU GPL, see COPYING for details.
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
10 """
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
11
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 999
diff changeset
12 import os
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
13 from xml.dom import getDOMImplementation
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
14 from xml.dom.ext.reader import Sax
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
15 from xml.dom.ext import Node
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
16
661
19ef5f9fff84 moved formatter.base to formatter.__init__
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 660
diff changeset
17 from MoinMoin.formatter import FormatterBase
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 999
diff changeset
18 from MoinMoin import wikiutil
86
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
19 from MoinMoin.error import CompositeError
200
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
20 from MoinMoin.action import AttachFile
86
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
21
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
22 class InternalError(CompositeError): pass
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
23
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
24 try:
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
25 dom = getDOMImplementation("4DOM")
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
26 except ImportError:
2233
666625ecde91 Fix error message in the docbook formatter, should be ported to 1.7.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 1796
diff changeset
27 raise InternalError("You need to install 4suite to use the DocBook formatter.")
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
28
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
29
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
30 class Formatter(FormatterBase):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
31
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
32 #this list is extended as the page is parsed. Could be optimized by adding them here?
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
33 section_should_break = ['abstract', 'para', 'emphasis']
3185
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
34
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
35 blacklisted_macros = ('TableOfContents', 'ShowSmileys')
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
36
3187
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
37 # If the current node is one of the following and we are about the emit
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
38 # text, the text should be wrapped in a paragraph
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
39 wrap_text_in_para = ('listitem', 'glossdef', 'article', 'chapter', 'tip', 'warning', 'note', 'caution', 'important')
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
40
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
41 def __init__(self, request, doctype="article", **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
42 FormatterBase.__init__(self, request, **kw)
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
43 self.request = request
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
44
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
45 '''
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
46 If the formatter is used by the Include macro, it will set
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
47 is_included=True in which case we know we need to call startDocument
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
48 and endDocument from startContent and endContent respectively, since
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
49 the Include macro will not be calling them, and the formatter doesn't
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
50 work properly unless they are called.
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
51 '''
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
52 if kw.has_key("is_included") and kw["is_included"]:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
53 self.include_kludge = True
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
54 else:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
55 self.include_kludge = False
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
56
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
57 self.doctype = doctype
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
58 self.curdepth = 0
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
59 self.cur = None
86
5181bcd3feb5 Show a better error message if PyXML is not installed and the docbook formatter is used.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 82
diff changeset
60
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
61 def startDocument(self, pagename):
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
62 self.doc = dom.createDocument(None, self.doctype, dom.createDocumentType(
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
63 self.doctype, "-//OASIS//DTD DocBook XML V4.4//EN",
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
64 "http://www.docbook.org/xml/4.4/docbookx.dtd"))
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
65
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
66 self.title = pagename
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
67 self.root = self.doc.documentElement
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
68 self.curdepth = 0
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
69
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
70 #info = self.doc.createElement("articleinfo")
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
71 self._addTitleElement(self.title, targetNode=self.root)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
72 self.cur = self.root
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
73 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
74
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
75 def startContent(self, content_id="content", **kw):
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
76 if self.include_kludge and not self.cur:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
77 return self.startDocument("OnlyAnIdiotWouldCreateSuchaPage")
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
78 return ""
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
79
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
80 def endContent(self):
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
81 if self.include_kludge:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
82 return self.endDocument()
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
83 return ""
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
84
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
85 def endDocument(self):
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
86 from xml.dom.ext import PrettyPrint, Print
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
87 import StringIO
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
88
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
89 f = StringIO.StringIO()
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
90 Print(self.doc, f)
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
91 #PrettyPrint(self.doc, f)
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
92 txt = f.getvalue()
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
93 f.close()
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
94
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
95 self.cur = None
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
96 return txt
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
97
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
98 def text(self, text, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
99 if text == "\\n":
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
100 srcText = "\n"
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
101 else:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
102 srcText = text
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
103 if self.cur.nodeName == "screen":
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
104 if self.cur.lastChild is not None:
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
105 from xml.dom.ext import Node
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
106 if self.cur.lastChild.nodeType == Node.CDATA_SECTION_NODE:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
107 self.cur.lastChild.nodeValue = self.cur.lastChild.nodeValue + srcText
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
108 else:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
109 self.cur.appendChild(self.doc.createCDATASection(srcText))
3187
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
110 elif self.cur.nodeName in self.wrap_text_in_para:
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
111 """
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
112 If we already wrapped one text item in a para, we should add to that para
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
113 and not create a new one. Another question is if we should add a space?
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
114 """
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
115 if self.cur.lastChild is not None and self.cur.lastChild.nodeName == 'para':
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
116 self.cur.lastChild.appendChild(self.doc.createTextNode(srcText))
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
117 else:
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
118 self.paragraph(1)
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
119 self.text(text)
4232b56627c7 Only some elements can contain text-nodes directly, while other elements must have the text wrapped in a paragraph for them to be able to contain it. This commit adds support for wrapping textnodes in paragrap-elements when needed.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3186
diff changeset
120 self.paragraph(0)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
121 else:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
122 self.cur.appendChild(self.doc.createTextNode(srcText))
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
123 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
124
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
125 def heading(self, on, depth, **kw):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
126 while self.cur.nodeName in self.section_should_break:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
127 self.cur = self.cur.parentNode
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
128
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
129 if on:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
130 # try to go to higher level if needed
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
131 if depth <= self.curdepth:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
132 # number of levels we want to go higher
2450
3d08f1cb4429 pep8 whitespace fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
133 numberOfLevels = self.curdepth - depth + 1
1793
2a4caa295346 Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
134 for dummy in range(numberOfLevels):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
135 #find first non section node
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
136 while (self.cur.nodeName != "section" and self.cur.nodeName != "article"):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
137 self.cur = self.cur.parentNode
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
138
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
139 # I don't understand this code - looks like unnecessary -- maybe it is used to gain some vertical space for large headings?
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
140 # if len(self.cur.childNodes) < 3:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
141 # self._addEmptyNode("para")
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
142
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
143 # check if not top-level
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
144 if self.cur.nodeName != "article":
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
145 self.cur = self.cur.parentNode
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
146
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
147 section = self.doc.createElement("section")
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
148 self.cur.appendChild(section)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
149 self.cur = section
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
150
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
151 title = self.doc.createElement("title")
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
152 self.cur.appendChild(title)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
153 self.cur = title
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
154 self.curdepth = depth
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
155 else:
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
156 self.cur = self.cur.parentNode
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
157
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
158 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
159
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
160 def paragraph(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
161 FormatterBase.paragraph(self, on)
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
162
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
163 # Let's prevent para inside para
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
164 if on and self.cur.nodeName == "para":
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
165 return ""
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
166 return self._handleNode("para", on)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
167
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
168 def linebreak(self, preformatted=1):
3188
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
169 """
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
170 If preformatted, it will simply output a linebreak.
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
171 If we are in a paragraph, we will close it, and open another one.
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
172 """
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
173 if preformatted:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
174 self.text('\\n')
3188
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
175 elif self.cur.nodeName == "para":
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
176 self.paragraph(0)
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
177 self.paragraph(1)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
178 else:
3188
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
179 self._emitComment("Warning: Probably not emitting right sort of linebreak")
fd905ed64dff Added support for linebreaks in paragraphs by exiting the current paragraph element and creating a new one.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3187
diff changeset
180 self.text('\n')
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
181 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
182
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
183 def _handleNode(self, name, on, attributes=()):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
184 if on:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
185 node = self.doc.createElement(name)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
186 self.cur.appendChild(node)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
187 if len(attributes) > 0:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
188 for name, value in attributes:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
189 node.setAttribute(name, value)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
190 self.cur = node
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
191 else:
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
192 """
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
193 Because we prevent para inside para, we might get extra "please exit para"
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
194 when we are no longer inside one.
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
195
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
196 TODO: Maybe rethink the para in para case
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
197 """
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
198 if name == "para" and self.cur.nodeName != "para":
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
199 return ""
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
200
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
201 self.cur = self.cur.parentNode
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
202 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
203
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
204 ### Inline ##########################################################
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
205
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
206 def _handleFormatting(self, name, on, attributes=()):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
207 # We add all the elements we create to the list of elements that should not contain a section
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
208 if name not in self.section_should_break:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
209 self.section_should_break.append(name)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
210
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
211 return self._handleNode(name, on, attributes)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
212
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
213 def strong(self, on, **kw):
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
214 return self._handleFormatting("emphasis", on, (('role', 'strong'), ))
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
215
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
216 def emphasis(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
217 return self._handleFormatting("emphasis", on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
218
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
219 def underline(self, on, **kw):
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
220 return self._handleFormatting("emphasis", on, (('role', 'underline'), ))
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
221
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
222 def highlight(self, on, **kw):
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
223 return self._handleFormatting("emphasis", on, (('role', 'highlight'), ))
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
224
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
225 def sup(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
226 return self._handleFormatting("superscript", on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
227
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
228 def sub(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
229 return self._handleFormatting("subscript", on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
230
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
231 def strike(self, on, **kw):
264
67e1f1d49a97 Fixed XML formatters.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 217
diff changeset
232 # does not yield <strike> using the HTML XSLT files here ...
67e1f1d49a97 Fixed XML formatters.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 217
diff changeset
233 # but seems to be correct
217
98df82a31b87 Added strike() to non HTML formatters. PLEASE REVIEW the xml_docbook FORMATTER!
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 200
diff changeset
234 return self._handleFormatting("emphasis", on,
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
235 (('role', 'strikethrough'), ))
217
98df82a31b87 Added strike() to non HTML formatters. PLEASE REVIEW the xml_docbook FORMATTER!
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 200
diff changeset
236
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
237 def code(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
238 return self._handleFormatting("code", on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
239
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
240 def preformatted(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
241 return self._handleFormatting("screen", on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
242
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
243
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
244 ### Lists ###########################################################
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
245
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
246 def number_list(self, on, type=None, start=None, **kw):
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
247 docbook_ol_types = {'1': "arabic",
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
248 'a': "loweralpha",
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
249 'A': "upperalpha",
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
250 'i': "lowerroman",
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
251 'I': "upperroman"}
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
252
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
253 if type and docbook_ol_types.has_key(type):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
254 attrs = [("numeration", docbook_ol_types[type])]
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
255 else:
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
256 attrs = []
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
257
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
258 return self._handleNode('orderedlist', on, attrs)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
259
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
260 def bullet_list(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
261 return self._handleNode("itemizedlist", on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
262
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
263 def definition_list(self, on, **kw):
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
264 return self._handleNode("glosslist", on)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
265
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
266 def definition_term(self, on, compact=0, **kw):
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
267 # When on is false, we back out just on level. This is
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
268 # ok because we know definition_desc gets called, and we
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
269 # back out two levels there.
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
270 if on:
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
271 entry = self.doc.createElement('glossentry')
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
272 term = self.doc.createElement('glossterm')
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
273 entry.appendChild(term)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
274 self.cur.appendChild(entry)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
275 self.cur = term
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
276 else:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
277 self.cur = self.cur.parentNode
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
278 return ""
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
279
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
280 def definition_desc(self, on, **kw):
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
281 # We backout two levels when 'on' is false, to leave the glossentry stuff
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
282 if on:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
283 return self._handleNode("glossdef", on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
284 else:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
285 self.cur = self.cur.parentNode.parentNode
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
286 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
287
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
288 def listitem(self, on, **kw):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
289 if on:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
290 node = self.doc.createElement("listitem")
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
291 self.cur.appendChild(node)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
292 self.cur = node
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
293 else:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
294 self.cur = self.cur.parentNode
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
295 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
296
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
297
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
298 ### Links ###########################################################
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
299
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
300 # FIXME: This is quite crappy
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
301 def pagelink(self, on, pagename='', page=None, **kw):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
302 FormatterBase.pagelink(self, on, pagename, page, **kw)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
303
1796
57f12932915f cleaning up comments, minor refactorings in heading formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1793
diff changeset
304 return self.interwikilink(on, 'Self', pagename)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
305
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
306 # FIXME: This is even more crappy
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
307 def interwikilink(self, on, interwiki='', pagename='', **kw):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
308 if not on:
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
309 return self.url(on, kw)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
310
2728
59b3d8b8971f remove (un)quoteName, new functions split_interwiki() and resolve_interwiki(), cleanup interwiki mess, fix some link markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
311 wikitag, wikiurl, wikitail, wikitag_bad = wikiutil.resolve_interwiki(self.request, interwiki, pagename)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
312 wikiurl = wikiutil.mapURL(self.request, wikiurl)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
313 href = wikiutil.join_wiki(wikiurl, wikitail)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
314
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
315 return self.url(on, href)
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
316
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
317 def url(self, on, url=None, css=None, **kw):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
318 return self._handleNode("ulink", on, (('url', url), ))
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
319
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
320 def anchordef(self, name):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
321 self._handleNode("anchor", True, (('id', name), ))
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
322 self._handleNode("ulink", False)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
323 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
324
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
325 def anchorlink(self, on, name='', **kw):
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
326 id = kw.get('id', None)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
327 attrs = []
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
328 if name != '':
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
329 attrs.append(('endterm', name))
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
330 if id is not None:
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
331 attrs.append(('linkend', id))
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
332 elif name != '':
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
333 attrs.append(('linkend', name))
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
334
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
335 return self._handleNode("link", on, attrs)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
336
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
337 ### Attachments ######################################################
200
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
338
2701
398af77c7ede fixed attachment_link api - it now has a 'on' parameter like most of the other methods
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
339 def attachment_link(self, on, url=None, **kw):
3008
f8738a94d990 fix attachment_link of docbook formatter (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
340 assert on in (0, 1, False, True) # make sure we get called the new way, not like the 1.5 api was
2701
398af77c7ede fixed attachment_link api - it now has a 'on' parameter like most of the other methods
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
341 # we do not output a "upload link" when outputting docbook
398af77c7ede fixed attachment_link api - it now has a 'on' parameter like most of the other methods
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
342 if on:
3008
f8738a94d990 fix attachment_link of docbook formatter (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
343 pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
f8738a94d990 fix attachment_link of docbook formatter (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
344 fname = wikiutil.taintfilename(filename)
f8738a94d990 fix attachment_link of docbook formatter (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2779
diff changeset
345 target = AttachFile.getAttachUrl(pagename, filename, self.request)
2701
398af77c7ede fixed attachment_link api - it now has a 'on' parameter like most of the other methods
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
346 return self.url(1, target, title="attachment:%s" % url)
200
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
347 else:
2701
398af77c7ede fixed attachment_link api - it now has a 'on' parameter like most of the other methods
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2450
diff changeset
348 return self.url(0)
200
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
349
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
350 def attachment_image(self, url, **kw):
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
351 _ = self.request.getText
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
352 pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
353 fname = wikiutil.taintfilename(filename)
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
354 fpath = AttachFile.getFilename(self.request, pagename, fname)
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
355 if not os.path.exists(fpath):
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
356 return self.text("[attachment:%s]" % url)
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
357 else:
3150
8ae94675b9f9 AttachFile: some cosmetical source changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3008
diff changeset
358 src = AttachFile.getAttachUrl(pagename, filename, self.request, addts=1)
8ae94675b9f9 AttachFile: some cosmetical source changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3008
diff changeset
359 return self.image(src=src, title="attachment:%s" % url)
200
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
360
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
361 def attachment_drawing(self, url, text, **kw):
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
362 _ = self.request.getText
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
363 pagename, filename = AttachFile.absoluteName(url, self.page.page_name)
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
364 fname = wikiutil.taintfilename(filename)
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
365 drawing = fname
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
366 fname = fname + ".png"
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
367 filename = filename + ".png"
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 999
diff changeset
368 fpath = AttachFile.getFilename(self.request, pagename, fname)
200
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
369 if not os.path.exists(fpath):
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
370 return self.text("[drawing:%s]" % url)
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
371 else:
3158
3ea8d2e4af32 minor whitespace fix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3150
diff changeset
372 src = AttachFile.getAttachUrl(pagename, filename, self.request, addts=1)
3150
8ae94675b9f9 AttachFile: some cosmetical source changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3008
diff changeset
373 return self.image(alt=drawing, src=src, html_class="drawing")
200
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
374
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
375 ### Images and Smileys ##############################################
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
376
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
377 def image(self, src=None, **kw):
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
378 if src:
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
379 kw['src'] = src
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
380 media = self.doc.createElement('inlinemediaobject')
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
381
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
382 imagewrap = self.doc.createElement('imageobject')
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
383 media.appendChild(imagewrap)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
384
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
385 image = self.doc.createElement('imagedata')
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
386 if kw.has_key('src'):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
387 image.setAttribute('fileref', kw['src'])
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
388 if kw.has_key('width'):
734
bf2435e61f97 moved smileys from MoinMoin.config to theme, fixed smiley text_python caching bug
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 661
diff changeset
389 image.setAttribute('width', str(kw['width']))
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
390 if kw.has_key('height'):
734
bf2435e61f97 moved smileys from MoinMoin.config to theme, fixed smiley text_python caching bug
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 661
diff changeset
391 image.setAttribute('depth', str(kw['height']))
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
392 imagewrap.appendChild(image)
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
393
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
394 title = ''
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
395 for a in ('title', 'html_title', 'alt', 'html_alt'):
466
de6f08a584fa fix broken smileys for docbook formatter
Thomas Waldmann <tw@waldmann-edv.de>
parents: 407
diff changeset
396 if kw.has_key(a):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
397 title = kw[a]
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
398 break
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
399 if title:
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
400 txtcontainer = self.doc.createElement('textobject')
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
401 media.appendChild(txtcontainer)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
402 txtphrase = self.doc.createElement('phrase')
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
403 txtphrase.appendChild(self.doc.createTextNode(title))
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
404 txtcontainer.appendChild(txtphrase)
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
405
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
406 self.cur.appendChild(media)
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
407 return ""
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
408
2713
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
409 def transclusion(self, on, **kw):
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
410 # TODO, see text_html formatter
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
411 return ""
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
412
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
413 def transclusion_param(self, **kw):
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
414 # TODO, see text_html formatter
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
415 return ""
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
416
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
417 def smiley(self, text):
734
bf2435e61f97 moved smileys from MoinMoin.config to theme, fixed smiley text_python caching bug
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 661
diff changeset
418 return self.request.theme.make_icon(text)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
419
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
420 def icon(self, type):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
421 return '' # self.request.theme.make_icon(type)
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
422
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
423
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
424 ### Code ############################################################
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
425
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
426 def code_area(self, on, code_id, code_type='code', show=0, start=-1, step=-1):
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
427 show = show and 'numbered' or 'unnumbered'
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
428 if start < 1:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
429 start = 1
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
430
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
431 attrs = (('id', code_id),
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
432 ('linenumbering', show),
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
433 ('startinglinenumber', str(start)),
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
434 ('language', code_type),
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
435 ('format', 'linespecific'),
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
436 )
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
437 return self._handleFormatting("screen", on, attrs)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
438
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
439 def code_line(self, on):
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
440 return '' # No clue why something should be done here
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
441
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
442 def code_token(self, on, tok_type):
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
443 toks_map = {'ID': 'methodname',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
444 'Operator': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
445 'Char': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
446 'Comment': 'lineannotation',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
447 'Number': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
448 'String': 'phrase',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
449 'SPChar': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
450 'ResWord': 'token',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
451 'ConsWord': 'symbol',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
452 'Error': 'errortext',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
453 'ResWord2': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
454 'Special': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
455 'Preprc': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
456 'Text': ''}
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
457 if toks_map.has_key(tok_type) and toks_map[tok_type] != '':
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
458 return self._handleFormatting(toks_map[tok_type], on)
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
459 else:
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
460 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
461
2779
c9dd12befda7 wiki parser: match everything looking like a macro and either execute it (macro imports ok) or render the macro markup as text (macro import fails, error msg is in title). This makes scan_rules independent of wiki, so we can move all re.compile time to Parser class (doing it only once on module import time).
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2754
diff changeset
462 def macro(self, macro_obj, name, args, markup=None):
3185
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
463 if name in self.blacklisted_macros:
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
464 self._emitComment("The macro %s doesn't work with the DocBook formatter." % name)
3186
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
465
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
466 elif name == "FootNote":
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
467 footnote = self.doc.createElement('footnote')
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
468 para = self.doc.createElement('para')
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
469 para.appendChild(self.doc.createTextNode(str(args)))
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
470 footnote.appendChild(para)
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
471 self.cur.appendChild(footnote)
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
472
3185
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
473 elif name == "Include":
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
474 text = FormatterBase.macro(self, macro_obj, name, args)
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
475 if text.strip():
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
476 self._copyExternalNodes(Sax.FromXml(text).documentElement.childNodes, exclude=("title",))
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
477 else:
3185
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
478 text = FormatterBase.macro(self, macro_obj, name, args)
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
479 if text:
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
480 from xml.parsers.expat import ExpatError
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
481 try:
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
482 self._copyExternalNodes(Sax.FromXml(text).documentElement.childNodes, exclude=excludes)
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
483 except ExpatError:
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
484 self._emitComment("The macro %s caused an error and should be blacklisted. It returned the data '%s' which caused the docbook-formatter to choke. Please file a bug." % (name, text))
5e0aede39dea - The DocBook formatter will try to execute any macros it encounters and will
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3184
diff changeset
485
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
486 return u""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
487
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
488 def _copyExternalNodes(self, nodes, deep=1, target=None, exclude=()):
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
489 if not target:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
490 target = self.cur
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
491
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
492 for node in nodes:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
493 if node.nodeName in exclude:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
494 pass
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
495 elif target.nodeName == "para" and node.nodeName == "para":
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
496 self._copyExternalNodes(node.childNodes, target=target)
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
497 self.cur = target.parentNode
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
498 else:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
499 target.appendChild(self.doc.importNode(node, deep))
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
500
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
501 def _emitComment(self, text):
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
502 text = text.replace("--", "- -") # There cannot be "--" in XML comment
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
503 self.cur.appendChild(self.doc.createComment(text))
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
504
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
505 def _addTitleElement(self, titleTxt, targetNode=None):
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
506 if not targetNode:
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
507 targetNode = self.cur
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
508 title = self.doc.createElement("title")
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
509 title.appendChild(self.doc.createTextNode(titleTxt))
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
510 targetNode.appendChild(title)
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
511
3189
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
512 def _convertStylesToDict(self, styles):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
513 '''Takes the CSS styling information and converts it to a dict'''
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
514 attrs = {}
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
515 for s in styles.split(";"):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
516 if s.strip(' "') == "":
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
517 continue
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
518 (key, value) = s.split(":", 1)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
519 key = key.strip(' "')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
520 value = value.strip(' "')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
521
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
522 if key == 'vertical-align':
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
523 key = 'valign'
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
524 elif key == 'text-align':
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
525 key = 'align'
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
526 elif key == 'background-color':
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
527 key = 'bgcolor'
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
528
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
529 attrs[key] = value
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
530 return attrs
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
531
3183
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
532
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
533 ### Not supported ###################################################
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
534
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
535 def rule(self, size=0, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
536 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
537
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
538 def small(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
539 return ""
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
540
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
541 def big(self, on, **kw):
82
0da5d27c0c3c Integrated new additions by Petr into the DocBook formatter. This includes better macro support, better heading semantics and cleaner include-macro results. Fixed line endings.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 0
diff changeset
542 return ""
407
bea43f99cc27 star-merged moin--refactor--1.5 (formatter, parser, converter fixes, see docs/CHANGES.refactor)
Thomas Waldmann <tw@waldmann-edv.de>
parents: 264
diff changeset
543
3189
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
544 ### Tables ##########################################################
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
545
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
546 def table(self, on, attrs=(), **kw):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
547 if(on):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
548 self.curtable = Table(self, self.doc, self.cur, attrs)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
549 self.cur = self.curtable.tableNode
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
550 else:
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
551 self.cur = self.curtable.finalizeTable()
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
552 self.curtable = None
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
553 return ""
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
554
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
555 def table_row(self, on, attrs=(), **kw):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
556 if(on):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
557 self.cur = self.curtable.addRow(attrs)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
558 return ""
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
559
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
560 def table_cell(self, on, attrs=(), **kw):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
561 if(on):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
562 self.cur = self.curtable.addCell(attrs)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
563 return ""
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
564
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
565 class Table:
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
566 '''The Table class is used as a helper for collecting information about
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
567 what kind of table we are building. When all relelvant data is gathered
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
568 it calculates the different spans of the cells and columns.
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
569 '''
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
570
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
571 def __init__(self, formatter, doc, parent, args):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
572 self.formatter = formatter
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
573 self.doc = doc
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
574
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
575 self.tableNode = self.doc.createElement('informaltable')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
576 parent.appendChild(self.tableNode)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
577 self.colWidths = {}
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
578 self.tgroup = self.doc.createElement('tgroup')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
579 # Bug in yelp, the two lines below don't affect rendering
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
580 #self.tgroup.setAttribute('rowsep', '1')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
581 #self.tgroup.setAttribute('colsep', '1')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
582 self.curColumn = 0
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
583 self.maxColumn = 0
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
584 self.row = None
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
585 self.tableNode.appendChild(self.tgroup)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
586
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
587 self.tbody = self.doc.createElement('tbody') # Note: This gets appended in finalizeTable
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
588
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
589 def finalizeTable(self):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
590 """Calculates the final width of the whole table and the width of each
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
591 column. Adds the colspec-elements and applies the colwidth attributes.
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
592 Inserts the tbody element to the tgroup and returns the tables container
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
593 element.
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
594
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
595 A lot of the information is gathered from the style attributes passed
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
596 to the functions
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
597 """
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
598 self.tgroup.setAttribute('cols', str(self.maxColumn))
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
599 for colnr in range(0, self.maxColumn):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
600 colspecElem = self.doc.createElement('colspec')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
601 colspecElem.setAttribute('colname', 'col_%s' % str(colnr))
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
602 if self.colWidths.has_key(str(colnr)) and self.colWidths[str(colnr)] != "1*":
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
603 colspecElem.setAttribute('colwidth', self.colWidths[str(colnr)])
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
604 self.tgroup.appendChild(colspecElem)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
605 self.tgroup.appendChild(self.tbody)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
606 return self.tableNode.parentNode
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
607
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
608 def addRow(self, args):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
609 self.curColumn = 0
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
610 self.row = self.doc.createElement('row')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
611 # Bug in yelp, doesn't affect the outcome.
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
612 #self.row.setAttribute("rowsep", "1") #Rows should have lines between them
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
613 self.tbody.appendChild(self.row)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
614 return self.row
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
615
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
616 def addCell(self, args):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
617 cell = self.doc.createElement('entry')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
618 cell.setAttribute('rowsep', '1')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
619 cell.setAttribute('colsep', '1')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
620
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
621 self.row.appendChild(cell)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
622
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
623 args = self._convertStyleAttributes(args)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
624 self._handleSimpleCellAttributes(cell, args)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
625 self._handleColWidth(args)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
626 self.curColumn += self._handleColSpan(cell, args)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
627
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
628 self.maxColumn = max(self.curColumn, self.maxColumn)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
629
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
630 return cell
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
631
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
632 def _handleColWidth(self, args):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
633 if not args.has_key("width"):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
634 return
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
635 args["width"] = args["width"].strip('"')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
636 if not args["width"].endswith("%"):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
637 self.formatter._emitComment("Width %s not supported" % args["width"])
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
638 return
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
639
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
640 self.colWidths[str(self.curColumn)] = args["width"][:-1] + "*"
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
641
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
642 def _handleColSpan(self, element, args):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
643 """Returns the number of colums this entry spans"""
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
644 if not args or not args.has_key('colspan'):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
645 return 1
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
646 assert(element.nodeName == "entry")
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
647 extracols = int(args['colspan'].strip('"')) - 1
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
648 element.setAttribute('namest', "col_" + str(self.curColumn))
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
649 element.setAttribute('nameend', "col_" + str(self.curColumn + extracols))
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
650 return 1 + extracols
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
651
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
652 def _handleSimpleCellAttributes(self, element, args):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
653 safe_values_for = {'valign': ('top', 'middle', 'bottom'),
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
654 'align': ('left', 'center', 'right'),
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
655 }
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
656 if not args:
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
657 return
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
658 assert(element.nodeName == "entry")
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
659
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
660 if args.has_key('rowspan'):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
661 extrarows = int(args['rowspan'].strip('"')) - 1
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
662 element.setAttribute('morerows', str(extrarows))
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
663
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
664 if args.has_key('align'):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
665 value = args['align'].strip('"')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
666 if value in safe_values_for['align']:
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
667 element.setAttribute('align', value)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
668 else:
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
669 self.formatter._emitComment("Alignment %s not supported" % value)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
670 pass
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
671
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
672 if args.has_key('valign'):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
673 value = args['valign'].strip('"')
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
674 if value in safe_values_for['valign']:
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
675 element.setAttribute('valign', value)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
676 else:
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
677 self.formatter._emitComment("Vertical alignment %s not supported" % value)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
678 pass
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
679
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
680 def _convertStyleAttributes(self, argslist):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
681 if not argslist.has_key('style'):
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
682 return argslist
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
683 styles = self.formatter._convertStylesToDict(argslist['style'].strip('"'))
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
684 argslist.update(styles)
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
685
c13eca15e247 Completely reworked table support, including:
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3188
diff changeset
686 return argslist