Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: third_party/twisted_8_1/twisted/lore/docbook.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 #
5
6 from cStringIO import StringIO
7 import os, re, cgi
8 from twisted.python import text
9 from twisted.web import domhelpers, microdom
10 import latex, tree
11
12 class DocbookSpitter(latex.BaseLatexSpitter):
13
14 currentLevel = 1
15
16 def writeNodeData(self, node):
17 self.writer(node.data)
18
19 def visitNode_body(self, node):
20 self.visitNodeDefault(node)
21 self.writer('</section>'*self.currentLevel)
22
23 def visitNodeHeader(self, node):
24 level = int(node.tagName[1])
25 difference, self.currentLevel = level-self.currentLevel, level
26 self.writer('<section>'*difference+'</section>'*-difference)
27 if difference<=0:
28 self.writer('</section>\n<section>')
29 self.writer('<title>')
30 self.visitNodeDefault(node)
31
32 def visitNode_a_listing(self, node):
33 fileName = os.path.join(self.currDir, node.getAttribute('href'))
34 self.writer('<programlisting>\n')
35 self.writer(cgi.escape(open(fileName).read()))
36 self.writer('</programlisting>\n')
37
38 def visitNode_a_href(self, node):
39 self.visitNodeDefault(node)
40
41 def visitNode_a_name(self, node):
42 self.visitNodeDefault(node)
43
44 def visitNode_li(self, node):
45 for child in node.childNodes:
46 if getattr(child, 'tagName', None) != 'p':
47 new = microdom.Element('p')
48 new.childNodes = [child]
49 node.replaceChild(new, child)
50 self.visitNodeDefault(node)
51
52 visitNode_h2 = visitNode_h3 = visitNode_h4 = visitNodeHeader
53 end_h2 = end_h3 = end_h4 = '</title><para />'
54 start_title, end_title = '<section><title>', '</title><para />'
55 start_p, end_p = '<para>', '</para>'
56 start_strong, end_strong = start_em, end_em = '<emphasis>', '</emphasis>'
57 start_span_footnote, end_span_footnote = '<footnote><para>', '</para></footn ote>'
58 start_q = end_q = '"'
59 start_pre, end_pre = '<programlisting>', '</programlisting>'
60 start_div_note, end_div_note = '<note>', '</note>'
61 start_li, end_li = '<listitem>', '</listitem>'
62 start_ul, end_ul = '<itemizedlist>', '</itemizedlist>'
63 start_ol, end_ol = '<orderedlist>', '</orderedlist>'
64 start_dl, end_dl = '<variablelist>', '</variablelist>'
65 start_dt, end_dt = '<varlistentry><term>', '</term>'
66 start_dd, end_dd = '<listitem><para>', '</para></listitem></varlistentry>'
OLDNEW
« no previous file with comments | « third_party/twisted_8_1/twisted/lore/default.py ('k') | third_party/twisted_8_1/twisted/lore/htmlbook.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698