| 89 | | |
|---|
| | 87 | |
|---|
| | 88 | def visit_title(self, node): |
|---|
| | 89 | """Coppied from html4css1.Writer wholesale just to get rid of the <a name=> crap. Fun, eh?""" |
|---|
| | 90 | check_id = 0 |
|---|
| | 91 | close_tag = '</p>\n' |
|---|
| | 92 | if isinstance(node.parent, nodes.topic): |
|---|
| | 93 | self.body.append( |
|---|
| | 94 | self.starttag(node, 'p', '', CLASS='topic-title first')) |
|---|
| | 95 | check_id = 1 |
|---|
| | 96 | elif isinstance(node.parent, nodes.sidebar): |
|---|
| | 97 | self.body.append( |
|---|
| | 98 | self.starttag(node, 'p', '', CLASS='sidebar-title')) |
|---|
| | 99 | check_id = 1 |
|---|
| | 100 | elif isinstance(node.parent, nodes.Admonition): |
|---|
| | 101 | self.body.append( |
|---|
| | 102 | self.starttag(node, 'p', '', CLASS='admonition-title')) |
|---|
| | 103 | check_id = 1 |
|---|
| | 104 | elif isinstance(node.parent, nodes.table): |
|---|
| | 105 | self.body.append( |
|---|
| | 106 | self.starttag(node, 'caption', '')) |
|---|
| | 107 | check_id = 1 |
|---|
| | 108 | close_tag = '</caption>\n' |
|---|
| | 109 | elif isinstance(node.parent, nodes.document): |
|---|
| | 110 | self.body.append(self.starttag(node, 'h1', '', CLASS='title')) |
|---|
| | 111 | self.context.append('</h1>\n') |
|---|
| | 112 | self.in_document_title = len(self.body) |
|---|
| | 113 | else: |
|---|
| | 114 | assert isinstance(node.parent, nodes.section) |
|---|
| | 115 | h_level = self.section_level + self.initial_header_level - 1 |
|---|
| | 116 | atts = {} |
|---|
| | 117 | if (len(node.parent) >= 2 and |
|---|
| | 118 | isinstance(node.parent[1], nodes.subtitle)): |
|---|
| | 119 | atts['CLASS'] = 'with-subtitle' |
|---|
| | 120 | node.ids = node.parent['ids'] |
|---|
| | 121 | self.body.append(self.starttag(node, 'h%s' % h_level, '', **atts)) |
|---|
| | 122 | self.context.append('</h%s>\n' % (h_level)) |
|---|
| | 123 | if check_id: |
|---|
| | 124 | if node.parent['ids']: |
|---|
| | 125 | self.body.append( |
|---|
| | 126 | self.starttag({}, 'a', '', name=node.parent['ids'][0])) |
|---|
| | 127 | self.context.append('</a>' + close_tag) |
|---|
| | 128 | else: |
|---|
| | 129 | self.context.append(close_tag) |
|---|
| | 130 | |
|---|
| | 131 | |
|---|