summaryrefslogtreecommitdiff
path: root/docutils/parsers/rst/directives/body.py
diff options
context:
space:
mode:
authorgoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-10-28 16:12:56 +0000
committergoodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2005-10-28 16:12:56 +0000
commit5eaa35732246484d010b80d2848eba8cd77158d8 (patch)
tree0b195e0c6680f2e84fb7a8c64a0c3e960a191e87 /docutils/parsers/rst/directives/body.py
parent1c603453f1653f485cf9246a50f5cb817cc7408c (diff)
downloaddocutils-5eaa35732246484d010b80d2848eba8cd77158d8.tar.gz
added the "container" element & directive, a generic container
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@3963 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, 27 insertions, 0 deletions
diff --git a/docutils/parsers/rst/directives/body.py b/docutils/parsers/rst/directives/body.py
index 28682328a..2ff89e617 100644
--- a/docutils/parsers/rst/directives/body.py
+++ b/docutils/parsers/rst/directives/body.py
@@ -167,3 +167,30 @@ def compound(name, arguments, options, content, lineno,
compound.options = {'class': directives.class_option}
compound.content = 1
+
+def container(name, arguments, options, content, lineno,
+ content_offset, block_text, state, state_machine):
+ text = '\n'.join(content)
+ if not text:
+ error = state_machine.reporter.error(
+ 'The "%s" directive is empty; content required.' % name,
+ nodes.literal_block(block_text, block_text), line=lineno)
+ return [error]
+ try:
+ if arguments:
+ classes = directives.class_option(arguments[0])
+ else:
+ classes = []
+ except ValueError:
+ error = state_machine.reporter.error(
+ 'Invalid class attribute value for "%s" directive: "%s".'
+ % (name, arguments[0]),
+ nodes.literal_block(block_text, block_text), line=lineno)
+ return [error]
+ node = nodes.container(text)
+ node['classes'].extend(classes)
+ state.nested_parse(content, content_offset, node)
+ return [node]
+
+container.arguments = (0, 1, 1)
+container.content = 1