summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authordkuhlman <dkuhlman@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2010-05-03 22:20:21 +0000
committerdkuhlman <dkuhlman@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2010-05-03 22:20:21 +0000
commit31da62a25c31e64de43216e4a52fc08e6f4a132e (patch)
tree94a88b4f8928890acd8998727957bcf46adf9ca2 /docutils
parent62f83e40e7920a64d8abd70fcfea6f2c2cddd9de (diff)
downloaddocutils-31da62a25c31e64de43216e4a52fc08e6f4a132e.tar.gz
Added support for legends inside a figure
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@6318 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/docs/user/odt.txt10
-rw-r--r--docutils/docutils/writers/odf_odt/__init__.py27
-rw-r--r--docutils/docutils/writers/odf_odt/styles.odtbin11051 -> 11121 bytes
3 files changed, 27 insertions, 10 deletions
diff --git a/docutils/docs/user/odt.txt b/docutils/docs/user/odt.txt
index ec3fd6128..6b7f0300e 100644
--- a/docutils/docs/user/odt.txt
+++ b/docutils/docs/user/odt.txt
@@ -241,6 +241,10 @@ rststyle-bodyindent
rststyle-bulletitem
An item in an bullet list.
+rststyle-caption
+ The caption in a figure or image. Also see
+ ``rststyle-legend``.
+
rststyle-codeblock
Literal code blocks -- A block of example code. Created with
double colon ("::") followed by an indented block or with the
@@ -286,6 +290,10 @@ rststyle-highlights-enumitem
rststyle-horizontalline
A horizontal line, e.g. used for transitions.
+rststyle-legend
+ The legend in a figure. See the Docutils figure directive. Also
+ see ``rststyle-caption``.
+
rststyle-table-title
The style for titles of tables. See section `The table
directive`_.
@@ -726,7 +734,7 @@ http://docutils.sourceforge.net/docs/ref/rst/directives.html#custom-interpreted-
<http://docutils.sourceforge.net/docs/ref/rst/directives.html#custom-interpreted-text-roles>`_.
**Note:** The ability to base a role on another existing role is
-not supported by ``odtwriter``.
+*not* supported by ``odtwriter``.
Hints and Suggestions and Features
diff --git a/docutils/docutils/writers/odf_odt/__init__.py b/docutils/docutils/writers/odf_odt/__init__.py
index 9150950ae..7f5356a62 100644
--- a/docutils/docutils/writers/odf_odt/__init__.py
+++ b/docutils/docutils/writers/odf_odt/__init__.py
@@ -695,7 +695,9 @@ class ODFTranslator(nodes.GenericNodeVisitor):
used_styles = (
'attribution', 'blockindent', 'blockquote', 'blockquote-bulletitem',
'blockquote-bulletlist', 'blockquote-enumitem', 'blockquote-enumlist',
- 'bulletitem', 'bulletlist', 'caption', 'centeredtextbody', 'codeblock',
+ 'bulletitem', 'bulletlist',
+ 'caption', 'legend',
+ 'centeredtextbody', 'codeblock',
'codeblock-classname', 'codeblock-comment', 'codeblock-functionname',
'codeblock-keyword', 'codeblock-name', 'codeblock-number',
'codeblock-operator', 'codeblock-string', 'emphasis', 'enumitem',
@@ -1910,7 +1912,7 @@ class ODFTranslator(nodes.GenericNodeVisitor):
attrib={'text:style-name': self.rststyle('textbody')})
el2 = el1
if isinstance(node.parent, docutils.nodes.figure):
- el3, el4, caption = self.generate_figure(node, source,
+ el3, el4, el5, caption = self.generate_figure(node, source,
destination, el2)
attrib = {
'draw:blue': '0%',
@@ -1938,10 +1940,10 @@ class ODFTranslator(nodes.GenericNodeVisitor):
'style:vertical-rel': 'paragraph-content',
'style:wrap': 'none',
}
- el5, width = self.generate_image(node, source, destination,
- el4, attrib)
+ el6, width = self.generate_image(node, source, destination,
+ el5, attrib)
if caption is not None:
- el5.tail = caption
+ el6.tail = caption
else: #if isinstance(node.parent, docutils.nodes.image):
el3 = self.generate_image(node, source, destination, el2)
@@ -2111,7 +2113,7 @@ class ODFTranslator(nodes.GenericNodeVisitor):
'text:style-name': self.rststyle('caption'),
}
el5 = SubElement(el4, 'text:p', attrib=attrib)
- return el3, el5, caption
+ return el3, el4, el5, caption
def generate_image(self, node, source, destination, current_element,
frame_attrs=None):
@@ -2205,11 +2207,18 @@ class ODFTranslator(nodes.GenericNodeVisitor):
return False
def visit_legend(self, node):
- # Currently, the legend receives *no* special treatment.
- pass
+ if isinstance(node.parent, docutils.nodes.figure):
+ el1 = self.current_element[-1]
+ el1 = el1[0][0]
+ self.current_element = el1
+ self.paragraph_style_stack.append(self.rststyle('legend'))
def depart_legend(self, node):
- pass
+ if isinstance(node.parent, docutils.nodes.figure):
+ self.paragraph_style_stack.pop()
+ self.set_to_parent()
+ self.set_to_parent()
+ self.set_to_parent()
def visit_line_block(self, node):
self.line_indent_level += 1
diff --git a/docutils/docutils/writers/odf_odt/styles.odt b/docutils/docutils/writers/odf_odt/styles.odt
index 9a50a8059..0f74587ff 100644
--- a/docutils/docutils/writers/odf_odt/styles.odt
+++ b/docutils/docutils/writers/odf_odt/styles.odt
Binary files differ