)
def visit_section(self, node):
+ atts = {}
+ if 'styles' in node: atts['styles'] = '; '.join(node['styles'])
self.section_level += 1
self.body.append(
- self.starttag(node, 'section'))
+ self.starttag(node, 'section', **atts))
def depart_section(self, node):
self.section_level -= 1
@@ -636,6 +638,54 @@ def depart_title(self, node):
self.html_title.extend(self.body)
del self.body[:]
+ ## h1–h6 elements must not be used to markup subheadings, subtitles,
+ ## alternative titles and taglines unless intended to be the heading for a
+ ## new section or subsection.
+ ## -- http://www.w3.org/TR/html/sections.html#headings-and-sections
+ #def visit_subtitle(self, node):
+ #if isinstance(node.parent, nodes.sidebar):
+ #classes = 'sidebar-subtitle'
+ #elif isinstance(node.parent, nodes.document):
+ #classes = 'subtitle'
+ #self.in_document_title = len(self.body)
+ #elif isinstance(node.parent, nodes.section):
+ #classes = 'section-subtitle'
+ #self.body.append(self.starttag(node, 'p', '', CLASS=classes))
+
+ #def depart_subtitle(self, node):
+ #self.body.append('\n')
+ #if self.in_document_title:
+ #self.subtitle = self.body[self.in_document_title:-1]
+ #self.in_document_title = 0
+ #self.body_pre_docinfo.extend(self.body)
+ #self.html_subtitle.extend(self.body)
+ #del self.body[:]
+ # Use
for subtitles (deprecated in HTML 5)
+ def visit_subtitle(self, node):
+ if isinstance(node.parent, nodes.sidebar):
+ self.body.append(self.starttag(node, 'p', '',
+ CLASS='sidebar-subtitle'))
+ self.context.append('\n')
+ elif isinstance(node.parent, nodes.document):
+ self.body.append(self.starttag(node, 'h2', '', CLASS='subtitle'))
+ self.context.append('\n')
+ self.in_document_title = len(self.body)
+ elif isinstance(node.parent, nodes.section):
+ tag = 'h%s' % (self.section_level + self.initial_header_level - 1)
+ self.body.append(
+ self.starttag(node, tag, '', CLASS='section-subtitle') +
+ self.starttag({}, 'span', '', CLASS='section-subtitle'))
+ self.context.append('%s>\n' % tag)
+
+ def depart_subtitle(self, node):
+ self.body.append(self.context.pop())
+ if self.in_document_title:
+ self.subtitle = self.body[self.in_document_title:-1]
+ self.in_document_title = 0
+ self.body_pre_docinfo.extend(self.body)
+ self.html_subtitle.extend(self.body)
+ del self.body[:]
+
# , , -- verbatim copied, removing "simple" class. For
# also removing the enumtype
def visit_bullet_list(self, node):