summaryrefslogtreecommitdiff
path: root/docutils/parsers/rst/directives/body.py
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2011-06-17 10:50:48 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2011-06-17 10:50:48 +0000
commit1249be38394bff38a206785a24ea2c82ab1c5f97 (patch)
tree7cb0c4f18a0bb93f56a095f6c952f20b938b1504 /docutils/parsers/rst/directives/body.py
parentca25a1ed6e205f8b6c0de495e975ad8e23df0c52 (diff)
downloaddocutils-1249be38394bff38a206785a24ea2c82ab1c5f97.tar.gz
Math directive and documentation update:
Math content can also be given as directive argument. Multiple content block separated by blank lines are put in separate nodes. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@7056 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils/parsers/rst/directives/body.py')
-rw-r--r--docutils/parsers/rst/directives/body.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py
index 9f4ba700a..e666ba29f 100644
--- a/docutils/parsers/rst/directives/body.py
+++ b/docutils/parsers/rst/directives/body.py
@@ -108,18 +108,33 @@ class ParsedLiteral(Directive):
node.line = self.content_offset + 1
return [node] + messages
+
class MathBlock(Directive):
- option_spec = {'class': directives.class_option}
has_content = True
+ required_arguments = 0
+ optional_arguments = 1
+ final_argument_whitespace = True
+ option_spec = {'class': directives.class_option
+ ## TODO: support Sphinx' ``mathbase.py`` options?
+ # 'label': directives.unchanged,
+ # 'nowrap': directives.flag,
+ }
def run(self):
set_classes(self.options)
- self.assert_has_content()
- latex_code = '\n'.join(self.content)
- node = nodes.math_block(self.block_text, latex_code, **self.options)
- node.line = self.content_offset + 1
- return [node]
+ if not self.arguments:
+ self.assert_has_content()
+ # join lines, separate blocks
+ content = '\n'.join(self.content).split('\n\n')
+ _nodes = []
+ for block in self.arguments + content:
+ if not block:
+ continue
+ node = nodes.math_block(self.block_text, block, **self.options)
+ node.line = self.content_offset + 1
+ _nodes.append(node)
+ return _nodes
class Rubric(Directive):