summaryrefslogtreecommitdiff
path: root/sandbox/html4strict
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2012-09-12 21:16:15 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2012-09-12 21:16:15 +0000
commitb3cc206e2a196df9f42a2141d5d2f887f6457861 (patch)
tree9a0df3338e83bc323016034908d48ebcfb13d6c5 /sandbox/html4strict
parent11c586df4c46feb1b6ab64461b81db23aff258a0 (diff)
downloaddocutils-b3cc206e2a196df9f42a2141d5d2f887f6457861.tar.gz
Simplify handling of "code" inline nodes.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7512 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/html4strict')
-rw-r--r--sandbox/html4strict/html4strict/__init__.py36
1 files changed, 27 insertions, 9 deletions
diff --git a/sandbox/html4strict/html4strict/__init__.py b/sandbox/html4strict/html4strict/__init__.py
index 80ab83120..0627f33a1 100644
--- a/sandbox/html4strict/html4strict/__init__.py
+++ b/sandbox/html4strict/html4strict/__init__.py
@@ -168,7 +168,7 @@ class HTMLTranslator(html4css1.HTMLTranslator):
def depart_docinfo(self, node):
self.body.append('</dl>\n')
- def visit_docinfo_item(self, node, name, meta=1):
+ def visit_docinfo_item(self, node, name, meta=True):
if meta:
meta_tag = '<meta name="%s" content="%s" />\n' \
% (name, self.attval(node.astext()))
@@ -252,8 +252,8 @@ class HTMLTranslator(html4css1.HTMLTranslator):
def depart_footnote(self, node):
self.body.append('</dd>\n')
- next_siblings = node.traverse(descend=0, siblings=1,
- include_self=0)
+ next_siblings = node.traverse(descend=False, siblings=True,
+ include_self=False)
next = next_siblings and next_siblings[0]
if isinstance(next, nodes.footnote):
self.body.append('<-- next footnote -->')
@@ -298,8 +298,8 @@ class HTMLTranslator(html4css1.HTMLTranslator):
# Content already processed:
raise nodes.SkipNode
- def depart_generated(self, node):
- pass
+ # def depart_generated(self, node):
+ # pass
# Do not mark the first child with 'class="first"'
def visit_list_item(self, node):
@@ -307,7 +307,13 @@ class HTMLTranslator(html4css1.HTMLTranslator):
# inline literal
def visit_literal(self, node):
- """Process text to prevent in-word line wrapping."""
+ # special case: "code" role
+ classes = node.get('classes', [])
+ if 'code' in classes:
+ # filter 'code' from class arguments
+ node['classes'] = [cls for cls in classes if cls != 'code']
+ self.body.append(self.starttag(node, 'code', ''))
+ return
self.body.append(
self.starttag(node, 'tt', '', CLASS='literal'))
text = node.astext()
@@ -326,6 +332,10 @@ class HTMLTranslator(html4css1.HTMLTranslator):
# Content already processed:
raise nodes.SkipNode
+ def depart_literal(self, node):
+ # skipped unless literal element is from "code" role:
+ self.body.append('</code>')
+
# literal block and doctest block: no newline after <pre> tag
# (leads to blank line in XHTML1.1)
def visit_literal_block(self, node,):
@@ -409,9 +419,9 @@ class HTMLTranslator(html4css1.HTMLTranslator):
):
self.body.append('\n')
-
- # no hard-coded border setting in the table head
- # ----------------------------------------------
+ # tables
+ # ------
+ # no hard-coded border setting in the table head::
def visit_table(self, node):
classes = [cls.strip(u' \t\n')
@@ -420,6 +430,14 @@ class HTMLTranslator(html4css1.HTMLTranslator):
self.body.append(tag)
+ # no hard-coded vertical alignment in table body::
+
+ def visit_tbody(self, node):
+ self.write_colspecs()
+ self.body.append(self.context.pop()) # '</colgroup>\n' or ''
+ self.body.append(self.starttag(node, 'tbody'))
+
+
class SimpleListChecker(html4css1.SimpleListChecker):
"""