annotate MoinMoin/formatter/text_docbook.py @ 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.
author Mikko Virkkil? <mvirkkil@cc.hut.fi>
date Wed, 05 Mar 2008 00:46:53 +0100
parents a36faa9f9d9f
children fd905ed64dff
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):
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
169 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
170 self.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
171 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
172 #this should not happen
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
173 #self.text('CRAP')
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
174 pass
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
175 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
176
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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 else:
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
186 """
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
187 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
188 when we are no longer inside one.
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
189
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
190 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
191 """
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
192 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
193 return ""
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
194
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
195 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
196 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
197
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
198 def _addEmptyNode(self, name, 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
199 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
200 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
201 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
202 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
203 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
204
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 def _getTableCellCount(self, 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
206 cols = 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
207 if attrs and attrs.has_key('colspan'):
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
208 s1 = attrs['colspan']
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
209 s1 = str(s1).replace('"', '')
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
210 cols = int(s1)
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 cols
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
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
213 def _addTableCellDefinition(self, 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
214 # Check number of columns
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 cols = self._getTableCellCount(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
216 # Find node tgroup
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 actNode = self.cur
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 numberExistingColumns = 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
219 while actNode and actNode.nodeName != 'tgroup':
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
220 actNode = actNode.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
221 # Number of existing columns
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
222 nodeBefore = self.cur
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
223 if actNode:
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 nodeBefore = actNode.firstChild
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
225 while nodeBefore and nodeBefore.nodeName != 'tbody':
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 nodeBefore = nodeBefore.nextSibling
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 numberExistingColumns += 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
228
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 while cols >= 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
230 # Create new 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
231 numberExistingColumns += 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
232 nnode = self.doc.createElement("colspec")
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
233 nnode.setAttribute('colname', 'xxx' + str(numberExistingColumns))
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
234 # Add 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
235 if actNode:
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
236 actNode.insertBefore(nnode, nodeBefore)
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
237 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
238 self.cur.insertBefore(nnode, nodeBefore)
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 cols -= 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
240 # Set new number of columns for tgroup
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 self.cur.parentNode.parentNode.parentNode.setAttribute('cols', str(numberExistingColumns))
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 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
243
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
244
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
245 ### 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
246
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
247 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
248 # 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
249 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
250 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
251
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 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
253
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 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
255 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
256
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
257 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
258 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
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 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
261 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
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 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
264 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
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 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
267 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
268
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
269 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
270 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
271
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
272 def strike(self, on, **kw):
264
67e1f1d49a97 Fixed XML formatters.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 217
diff changeset
273 # does not yield <strike> using the HTML XSLT files here ...
67e1f1d49a97 Fixed XML formatters.
Alexander Schremmer <alex@alexanderweb.de.tla>
parents: 217
diff changeset
274 # 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
275 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
276 (('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
277
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
278 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
279 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
280
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
281 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
282 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
283
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
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 ### 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
286
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
287 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
288 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
289 '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
290 '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
291 '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
292 '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
293
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 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
295 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
296 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
297 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
298
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 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
300
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
301 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
302 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
303
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
304 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
305 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
306
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
307 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
308 # 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
309 # 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
310 # 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
311 if on:
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
312 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
313 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
314 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
315 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
316 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
317 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
318 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
319 return ""
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
320
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
321 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
322 # 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
323 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
324 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
325 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
326 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
327 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
328
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 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337
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
338
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
339 ### 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
340
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
341 # 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
342 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
343 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
344
1796
57f12932915f cleaning up comments, minor refactorings in heading formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1793
diff changeset
345 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
346
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
347 # 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
348 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
349 if not on:
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
350 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
351
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
352 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
353 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
354 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
355
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
356 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
357
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
358 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
359 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
360
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
361 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
362 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
363 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
364 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
365
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
366 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
367 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
368 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
369 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
370 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
371 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
372 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
373 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
374 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
375
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 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
377
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
378 ### 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
379
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
380 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
381 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
382 # 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
383 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
384 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
385 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
386 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
387 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
388 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
389 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
390
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
391 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
392 _ = 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
393 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
394 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
395 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
396 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
397 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
398 else:
3150
8ae94675b9f9 AttachFile: some cosmetical source changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3008
diff changeset
399 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
400 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
401
7c5bba88937b attachment methods for the text_xml and xml_docbook formatters
Florian Festi <Florian.Festi@trick.informatik.uni-stuttgart.de>
parents: 159
diff changeset
402 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
403 _ = 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
404 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
405 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
406 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
407 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
408 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
409 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
410 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
411 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
412 else:
3158
3ea8d2e4af32 minor whitespace fix
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3150
diff changeset
413 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
414 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
415
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
416 ### 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
417
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
418 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
419 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
420 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
421 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
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 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
424 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
425
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 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
427 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
428 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
429 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
430 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
431 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
432 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
433 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
434
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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442 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
443 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
444 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
445 txtcontainer.appendChild(txtphrase)
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
446
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
447 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
448 return ""
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
449
2713
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
450 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
451 # 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
452 return ""
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
453
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
454 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
455 # 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
456 return ""
ddb2d19684d7 add transclusion / transclusion_param formatter methods (for html: <object> / <param>)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2701
diff changeset
457
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
458 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
459 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
460
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 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
462 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
463
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
464 ### Tables ##########################################################
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
465
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
466 #FIXME: We should copy code from text_html.py for attr handling
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
467
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
468 def table(self, on, attrs=None, **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
469 sanitized_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
470 if attrs and attrs.has_key('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
471 sanitized_attrs[id] = attrs['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
472
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
473 self._handleNode("table", on, sanitized_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
474 if on:
2274
01f6172dabd0 remove tabs from source files, remove excludes from test_tab
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2233
diff changeset
475 self._addEmptyNode("caption") #dtd for table requires caption
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
476 self._handleNode("tgroup", 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
477 self._handleNode("tbody", 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
478 return ""
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
479
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
480 def table_row(self, on, attrs=None, **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
481 self.table_current_row_cells = 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
482 sanitized_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
483 if attrs and attrs.has_key('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
484 sanitized_attrs[id] = attrs['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
485 return self._handleNode("row", on, sanitized_attrs)
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
486
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
487 def table_cell(self, on, attrs=None, **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
488 # Finish row definition
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
489 sanitized_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
490 if attrs and attrs.has_key('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
491 sanitized_attrs[id] = attrs['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
492 # Get number of newly added columns
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
493 startCount = self.table_current_row_cells
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
494 addedCellsCount = self._getTableCellCount(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
495 self.table_current_row_cells += addedCellsCount
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
496 ret = self._handleNode("entry", on, sanitized_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
497 if self.cur.parentNode == self.cur.parentNode.parentNode.firstChild:
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
498 self._addTableCellDefinition(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
499 # Set cell join if any
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
500 if addedCellsCount > 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
501 startString = "xxx" + str(startCount)
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
502 stopString = "xxx" + str(startCount + addedCellsCount - 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
503 self.cur.setAttribute("namest", startString)
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
504 self.cur.setAttribute("nameend", stopString)
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
505 return ret
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
506
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
507 ### 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
508
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
509 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
510 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
511 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
512 start = 1
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
513
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
514 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
515 ('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
516 ('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
517 ('language', code_type),
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
518 ('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
519 )
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
520 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
521
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
522 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
523 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
524
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
525 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
526 toks_map = {'ID': 'methodname',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
527 'Operator': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
528 'Char': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
529 'Comment': 'lineannotation',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
530 'Number': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
531 'String': 'phrase',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
532 'SPChar': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
533 'ResWord': 'token',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
534 'ConsWord': 'symbol',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
535 'Error': 'errortext',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
536 'ResWord2': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
537 'Special': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
538 'Preprc': '',
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2274
diff changeset
539 '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
540 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
541 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
542 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
543 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
544
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
545 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
546 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
547 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
548
a36faa9f9d9f Add support for the FootNote macro by creating a DocBook-native footnote.
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3185
diff changeset
549 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
550 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
551 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
552 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
553 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
554 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
555
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
556 elif name == "Include":
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
557 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
558 if text.strip():
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
559 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
560 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
561 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
562 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
563 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
564 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
565 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
566 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
567 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
568
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
569 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
570
3184
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
571 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
572 if not target:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
573 target = self.cur
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
574
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
575 for node in nodes:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
576 if node.nodeName in exclude:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
577 pass
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
578 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
579 self._copyExternalNodes(node.childNodes, target=target)
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
580 self.cur = target.parentNode
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
581 else:
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
582 target.appendChild(self.doc.importNode(node, deep))
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
583
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
584 def _emitComment(self, text):
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
585 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
586 self.cur.appendChild(self.doc.createComment(text))
4c7c12b775e0 - Add support for the Include macro
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3183
diff changeset
587
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
588 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
589 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
590 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
591 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
592 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
593 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
594
952f8f1268c5 - Remove dummy formatter which did a lot of stuff to output text, instead
Mikko Virkkil? <mvirkkil@cc.hut.fi>
parents: 3158
diff changeset
595
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
596 ### 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
597
999
97ce857bdebf whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 828
diff changeset
598 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
599 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
600
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
601 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
602 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
603
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
604 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
605 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
606