summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-05-09 22:39:27 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-05-09 22:39:27 +0000
commit6dc552ad0163b7534ea94bafd6b635b5c594558f (patch)
treee4731313a5c5565b8df044def91abddbbb5d8fda
parent435227f1f0aa9587874f77979c631338bbbd9ac5 (diff)
downloaddocutils-6dc552ad0163b7534ea94bafd6b635b5c594558f.tar.gz
added deletion of \Dcurrent... macros to avoid left-over attributes
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@3327 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--docutils/docutils/writers/newlatex2e.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/docutils/docutils/writers/newlatex2e.py b/docutils/docutils/writers/newlatex2e.py
index cc5368c1a..0aa011f60 100644
--- a/docutils/docutils/writers/newlatex2e.py
+++ b/docutils/docutils/writers/newlatex2e.py
@@ -72,6 +72,7 @@ class Writer(writers.Writer):
def translate(self):
visitor = self.translator_class(self.document)
self.document.walkabout(visitor)
+ assert not visitor.context, 'context not empty: %s' % visitor.context
self.output = visitor.astext()
self.head = visitor.header
self.body = visitor.body
@@ -573,8 +574,8 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
if isinstance(node.parent.parent, nodes.thead):
node['tableheaderentry'] = 'true'
- # Don't add \renewcommand{\Dparent}{...} because there may not
- # be any non-expandable commands in front of \multicolumn.
+ # Don't add \renewcommand{\Dparent}{...} because there must
+ # not be any non-expandable commands in front of \multicolumn.
raise SkipParentLaTeX
def depart_entry(self, node):
@@ -663,15 +664,19 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
if not isinstance(node, nodes.Text):
node_name = self.node_name(node)
+ # attribute_deleters will be appended to self.context.
+ attribute_deleters = []
if not skip_parent and not isinstance(node, nodes.document):
self.append(r'\renewcommand{\Dparent}{%s}'
% self.node_name(node.parent))
for name, value in node.attlist():
# @@@ Evaluate if this is really needed and refactor.
if not isinstance(value, ListType) and not ':' in name:
- self.append(r'\def\DcurrentN%sA%s{%s}'
- % (node_name, name,
- self.encode(unicode(value), attval=1)))
+ macro = r'\DcurrentN%sA%s' % (node_name, name)
+ self.append(r'\def%s{%s}' % (
+ macro, self.encode(unicode(value), attval=1)))
+ attribute_deleters.append(r'\let%s=\relax' % macro)
+ self.context.append('\n'.join(attribute_deleters))
if self.pass_contents(node):
self.append(r'\DN%s{' % node_name)
self.context.append('}')
@@ -732,7 +737,8 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
# Close attribute and node handler call (\DN...{...}).
self.indentation_level -= 1
self.append(self.context.pop() + self.context.pop())
-
+ # Delete \Dcurrent... attribute macros.
+ self.append(self.context.pop())
# Insert space.
if self.needs_space(node):
# Next sibling.