1 from docutils
.writers
import html4css1
2 from docutils
import nodes
4 class Writer(html4css1
.Writer
):
5 W_init
= html4css1
.Writer
.__init
__
8 self
.translator_class
= MyHTMLTranslator
10 def find_visible_child(node
, starting_index
, direction
):
11 if direction
== "forwards":
17 for i
in range(starting_index
, end
, step
):
18 if not isinstance(node
[i
], nodes
.Invisible
):
23 class MyHTMLTranslator(html4css1
.HTMLTranslator
):
24 def visit_title(self
, node
):
25 self
.body
.append(self
.starttag(node
, 'b', '',
26 STYLE
="font-variant: small-caps"))
27 self
.context
.append('</b>\n')
28 def visit_document(self
, node
):
30 def depart_document(self
, node
):
32 def visit_paragraph(self
, node
):
33 if isinstance(node
.parent
, nodes
.section
):
34 index
= node
.parent
.index(node
)
35 prev
= find_visible_child(node
.parent
, index
- 1, "backwards")
36 if isinstance(prev
, nodes
.title
):
37 self
.body
.append(self
.starttag(node
, 'blockquote', '\n'))
39 self
.body
.append('<p>\n')
41 html4css1
.HTMLTranslator
.visit_paragraph(self
, node
)
43 def depart_paragraph(self
, node
):
44 if isinstance(node
.parent
, nodes
.section
):
45 index
= node
.parent
.index(node
)
46 next
= find_visible_child(node
.parent
, index
+ 1, "forwards")
48 self
.body
.append('\n</blockquote>\n')
50 self
.body
.append("\n");
52 # this tends to include "</p>"s which advogato then
53 # discards. I don't care that much...
54 html4css1
.HTMLTranslator
.depart_paragraph(self
, node
)
56 def visit_section(self
, node
):
58 def depart_section(self
, node
):