blob: d01b7b9514527083c3280037f9e0fecca10c7f4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
"""
Writes <article>...</article> instead of <article><section>...</section></article>.
"""
import mwlib.docbookwriter
#import lxml.etree
Element = mwlib.docbookwriter.Element
SubElement = mwlib.docbookwriter.SubElement
class MyDocBookWriter(mwlib.docbookwriter.DocBookWriter):
def dbwriteArticle(self, a):
"""
this generates the root element if not available
"""
#e = super(MyDocBookWriter,self).dbwriteArticle(a)
#e.remove(e.find("section"))
#return e
# add head + title
e = Element("article", lang=self.language)
if self.root is None:
self.root = e
h = SubElement(e,"articleinfo")
t = SubElement(h, "title")
if a.caption:
t.text = a.caption
# DONT add a section and heading for this article
#s = SubElement(e, "section")
#si = SubElement(s, "sectioninfo")
#h = SubElement(si, "title")
#h.text = a.caption
#e.writeto = s
return e
def apply():
mwlib.docbookwriter.DocBookWriter = MyDocBookWriter
|