diff options
| author | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2004-01-12 16:27:25 +0000 |
|---|---|---|
| committer | goodger <goodger@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2004-01-12 16:27:25 +0000 |
| commit | 8a1d43e4d1fb6563db7da980e74873e128728ac8 (patch) | |
| tree | eaef6983cc3f5c5d2b113e2a1a3411a05e727adf | |
| parent | 09fb7b3846d5fd47922f7e06baee8c370992c33d (diff) | |
| download | docutils-8a1d43e4d1fb6563db7da980e74873e128728ac8.tar.gz | |
added "table" directive
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@1799 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
| -rw-r--r-- | docutils/HISTORY.txt | 23 | ||||
| -rw-r--r-- | docutils/docs/dev/todo.txt | 9 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/directives/__init__.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/directives/body.py | 35 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/af.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/cs.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/de.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/en.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/eo.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/es.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/fr.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/it.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/pt-br.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/ru.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/sk.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/parsers/rst/languages/sv.py | 1 | ||||
| -rw-r--r-- | docutils/docutils/writers/html4css1.py | 10 |
17 files changed, 77 insertions, 13 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 240761f1e..bf35db11d 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -20,15 +20,15 @@ and related projects: Aahz, David Abrahams, David Ascher, Heiko Baumann, Eric Bellot, Ian Bicking, Marek Blaha, Martin Blais, Fred Bremmer, Simon Budig, - Bill Bumgarner, Brett Cannon, Beni Cherniavsky, Adam Chodorowski, - Artur de Sousa Rocha, Jason Diamond, William Dode, Fred Drake, - Dethe Elza, Marcus Ertl, Benja Fallenstein, fantasai, Stefane - Fermigier, Jim Fulton, Peter Funk, Dinu C. Gherman, Jorge - Gonzalez, Engelbert Gruber, Simon Hefti, Doug Hellmann, Juergen - Hermann, Jannie Hofmeyr, Michael Hudson, Marcelo Huerta San - Martin, Ludger Humbert, Jeremy Hylton, Tony Ibbs, Alan Jaffray, - Dmitry Jemerov, Richard Jones, Andreas Jung, Garth Kidd, Axel - Kollmorgen, Kirill Lapshin, Nicola Larosa, Daniel Larsson, + Bill Bumgarner, Brett Cannon, Nicolas Chauveau, Beni Cherniavsky, + Adam Chodorowski, Artur de Sousa Rocha, Jason Diamond, William + Dode, Fred Drake, Dethe Elza, Marcus Ertl, Benja Fallenstein, + fantasai, Stefane Fermigier, Jim Fulton, Peter Funk, Dinu + C. Gherman, Jorge Gonzalez, Engelbert Gruber, Simon Hefti, Doug + Hellmann, Juergen Hermann, Jannie Hofmeyr, Michael Hudson, Marcelo + Huerta San Martin, Ludger Humbert, Jeremy Hylton, Tony Ibbs, Alan + Jaffray, Dmitry Jemerov, Richard Jones, Andreas Jung, Garth Kidd, + Axel Kollmorgen, Kirill Lapshin, Nicola Larosa, Daniel Larsson, Marc-Andre Lemburg, Julien Letessier, Wolfgang Lipp, Edward Loper, Dallas Mahrt, Ken Manheimer, Bob Marshall, Vasko Miroslav, Skip Montanaro, Paul Moore, Nigel W. Moriarty, Mark Nodine, Patrick @@ -161,6 +161,10 @@ Changes Since 0.3 - Catch unicode value too high error; fixes bug 781766. - Beefed up directive error reporting. +* docutils/parsers/rst/directives/body.py: + + - Added basic "table" directive. + * docutils/parsers/rst/directives/images.py: - Added "target" option to "image" directive. @@ -189,6 +193,7 @@ Changes Since 0.3 Kirill Lapshin). - Improved table grid/border handling (prompted by report from Bob Marshall). + - Added support for table titles. * docutils/writers/latex2e.py: diff --git a/docutils/docs/dev/todo.txt b/docutils/docs/dev/todo.txt index c66fc80f3..159b3a204 100644 --- a/docutils/docs/dev/todo.txt +++ b/docutils/docs/dev/todo.txt @@ -120,7 +120,7 @@ General .. figure:: image.png :name: image's name - To name tables, we could use a "table" directive:: + Same for the "table" directive:: .. table:: optional title here :name: table's name @@ -868,7 +868,12 @@ when used in a document. - Add a "name" option to directives, to set an author-supplied identifier? - - _`images.image`: "border"? "link"? + - All directives that produce titled elements should grow implicit + reference names based on the titles. + + - @ _`body.table`: Document, add tests. + + - _`images.image`: "border"? Units of measure? (See docutils-users, 2003-03-02.) diff --git a/docutils/docutils/parsers/rst/directives/__init__.py b/docutils/docutils/parsers/rst/directives/__init__.py index fdddb6c9d..23ef04188 100644 --- a/docutils/docutils/parsers/rst/directives/__init__.py +++ b/docutils/docutils/parsers/rst/directives/__init__.py @@ -102,6 +102,7 @@ _directive_registry = { 'epigraph': ('body', 'epigraph'), 'highlights': ('body', 'highlights'), 'pull-quote': ('body', 'pull_quote'), + 'table': ('body', 'table'), #'questions': ('body', 'question_list'), 'image': ('images', 'image'), 'figure': ('images', 'figure'), diff --git a/docutils/docutils/parsers/rst/directives/body.py b/docutils/docutils/parsers/rst/directives/body.py index 47e1423c8..122b2ccc4 100644 --- a/docutils/docutils/parsers/rst/directives/body.py +++ b/docutils/docutils/parsers/rst/directives/body.py @@ -120,3 +120,38 @@ def pull_quote(name, arguments, options, content, lineno, return [block_quote] + messages pull_quote.content = 1 + +def table(name, arguments, options, content, lineno, + content_offset, block_text, state, state_machine): + if not content: + warning = state_machine.reporter.warning( + 'Content block expected for the "%s" directive; none found.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + return [warning] + if arguments: + title_text = arguments[0] + text_nodes, messages = state.inline_text(title_text, lineno) + title = nodes.title(title_text, '', *text_nodes) + else: + title = None + node = nodes.Element() # anonymous container for parsing + text = '\n'.join(content) + state.nested_parse(content, content_offset, node) + if len(node) != 1 or not isinstance(node[0], nodes.table): + error = state_machine.reporter.error( + 'Error parsing content block for the "%s" directive: ' + 'exactly one table expected.' + % name, nodes.literal_block(block_text, block_text), + line=lineno) + return [error] + table_node = node[0] + if options.has_key('class'): + table_node.set_class(options['class']) + if title: + table_node.insert(0, title) + return [table_node] + +table.arguments = (0, 1, 1) +table.options = {'class': directives.class_option} +table.content = 1 diff --git a/docutils/docutils/parsers/rst/languages/af.py b/docutils/docutils/parsers/rst/languages/af.py index 8ad023ed1..f714ca9b1 100644 --- a/docutils/docutils/parsers/rst/languages/af.py +++ b/docutils/docutils/parsers/rst/languages/af.py @@ -36,6 +36,7 @@ directives = { 'epigraaf': 'epigraph', 'hoogtepunte': 'highlights', 'pull-quote (translation required)': 'pull-quote', + 'table (translation required)': 'table', #'vrae': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/cs.py b/docutils/docutils/parsers/rst/languages/cs.py index 45fb5e657..23c551140 100644 --- a/docutils/docutils/parsers/rst/languages/cs.py +++ b/docutils/docutils/parsers/rst/languages/cs.py @@ -37,6 +37,7 @@ directives = { u'moto': 'epigraph', u'highlights': 'highlights', u'pull-quote': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/de.py b/docutils/docutils/parsers/rst/languages/de.py index 017a2e851..cc3b71138 100644 --- a/docutils/docutils/parsers/rst/languages/de.py +++ b/docutils/docutils/parsers/rst/languages/de.py @@ -37,6 +37,7 @@ directives = { 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', # kasten too ? + 'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/en.py b/docutils/docutils/parsers/rst/languages/en.py index a9b060f82..d9068ee8e 100644 --- a/docutils/docutils/parsers/rst/languages/en.py +++ b/docutils/docutils/parsers/rst/languages/en.py @@ -37,6 +37,7 @@ directives = { 'epigraph': 'epigraph', 'highlights': 'highlights', 'pull-quote': 'pull-quote', + 'table': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/eo.py b/docutils/docutils/parsers/rst/languages/eo.py index 35c3a6765..0682f875c 100644 --- a/docutils/docutils/parsers/rst/languages/eo.py +++ b/docutils/docutils/parsers/rst/languages/eo.py @@ -40,6 +40,7 @@ directives = { u'elstara\u0135oj': 'highlights', u'ekstera-citajxo': 'pull-quote', u'ekstera-cita\u0135o': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/es.py b/docutils/docutils/parsers/rst/languages/es.py index abe883741..27cfb9301 100644 --- a/docutils/docutils/parsers/rst/languages/es.py +++ b/docutils/docutils/parsers/rst/languages/es.py @@ -42,6 +42,7 @@ directives = { u'epigrafe': 'epigraph', u'destacado': 'highlights', u'cita-destacada': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/fr.py b/docutils/docutils/parsers/rst/languages/fr.py index ba0bcb014..6ed792430 100644 --- a/docutils/docutils/parsers/rst/languages/fr.py +++ b/docutils/docutils/parsers/rst/languages/fr.py @@ -38,6 +38,7 @@ directives = { u'\u00E9pigraphe': 'epigraph', u'chapeau': 'highlights', u'accroche': 'pull-quote', + u'tableau': 'table', #u'questions': 'questions', #u'qr': 'questions', #u'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/it.py b/docutils/docutils/parsers/rst/languages/it.py index 911c69a66..035fd60c9 100644 --- a/docutils/docutils/parsers/rst/languages/it.py +++ b/docutils/docutils/parsers/rst/languages/it.py @@ -36,6 +36,7 @@ directives = { 'epigraph (translation required)': 'epigraph', 'highlights (translation required)': 'highlights', 'pull-quote (translation required)': 'pull-quote', + u'table (translation required)': 'table', #'questions': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/pt-br.py b/docutils/docutils/parsers/rst/languages/pt-br.py index 5fc68218a..309a4f39b 100644 --- a/docutils/docutils/parsers/rst/languages/pt-br.py +++ b/docutils/docutils/parsers/rst/languages/pt-br.py @@ -37,6 +37,7 @@ directives = { u'epígrafo': 'epigraph', 'destaques': 'highlights', u'citação-destacada': 'pull-quote', + u'table (translation required)': 'table', #'perguntas': 'questions', #'qa': 'questions', #'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/ru.py b/docutils/docutils/parsers/rst/languages/ru.py index 366f4505f..40823dd81 100644 --- a/docutils/docutils/parsers/rst/languages/ru.py +++ b/docutils/docutils/parsers/rst/languages/ru.py @@ -23,6 +23,7 @@ directives = { u'parsed-literal', u'\u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f-\u0446\u0438\u0442\u0430\u0442\u0430': u'pull-quote', + u'table (translation required)': 'table', u'\u0441\u044b\u0440\u043e\u0439': u'raw', u'\u0437\u0430\u043c\u0435\u043d\u0430': u'replace', u'\u0442\u0435\u0441\u0442\u043e\u0432\u0430\u044f-\u0434\u0438\u0440\u0435\u043a\u0442\u0438\u0432\u0430-restructuredtext': diff --git a/docutils/docutils/parsers/rst/languages/sk.py b/docutils/docutils/parsers/rst/languages/sk.py index caf3ed5c4..83f101908 100644 --- a/docutils/docutils/parsers/rst/languages/sk.py +++ b/docutils/docutils/parsers/rst/languages/sk.py @@ -36,6 +36,7 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', + u'table (translation required)': 'table', #u'questions': 'questions', #u'qa': 'questions', #u'faq': 'questions', diff --git a/docutils/docutils/parsers/rst/languages/sv.py b/docutils/docutils/parsers/rst/languages/sv.py index 04d105f90..3409c30f2 100644 --- a/docutils/docutils/parsers/rst/languages/sv.py +++ b/docutils/docutils/parsers/rst/languages/sv.py @@ -35,6 +35,7 @@ directives = { u'epigraph (translation required)': 'epigraph', u'highlights (translation required)': 'highlights', u'pull-quote (translation required)': 'pull-quote', + u'table (translation required)': 'table', # u'fr\u00e5gor': 'questions', # NOTE: A bit long, but recommended by http://www.nada.kth.se/dataterm/: # u'fr\u00e5gor-och-svar': 'questions', diff --git a/docutils/docutils/writers/html4css1.py b/docutils/docutils/writers/html4css1.py index 1760f3f19..566f5b67f 100644 --- a/docutils/docutils/writers/html4css1.py +++ b/docutils/docutils/writers/html4css1.py @@ -1141,6 +1141,7 @@ class HTMLTranslator(nodes.NodeVisitor): def visit_title(self, node): """Only 6 section levels are supported by HTML.""" check_id = 0 + close_tag = '</p>\n' if isinstance(node.parent, nodes.topic): self.body.append( self.starttag(node, 'p', '', CLASS='topic-title')) @@ -1153,6 +1154,11 @@ class HTMLTranslator(nodes.NodeVisitor): self.body.append( self.starttag(node, 'p', '', CLASS='admonition-title')) check_id = 1 + elif isinstance(node.parent, nodes.table): + self.body.append( + self.starttag(node, 'caption', '')) + check_id = 1 + close_tag = '</caption>\n' elif self.section_level == 0: # document title self.head.append('<title>%s</title>\n' @@ -1174,9 +1180,9 @@ class HTMLTranslator(nodes.NodeVisitor): if node.parent.hasattr('id'): self.body.append( self.starttag({}, 'a', '', name=node.parent['id'])) - self.context.append('</a></p>\n') + self.context.append('</a>' + close_tag) else: - self.context.append('</p>\n') + self.context.append(close_tag) def depart_title(self, node): self.body.append(self.context.pop()) |
