From 80c0ff4b0df01f03eeaa86a5fd987311d335f7a7 Mon Sep 17 00:00:00 2001 From: Christophe de Vienne Date: Tue, 12 May 2009 17:15:34 +0200 Subject: [PATCH] #19: Remove the 'longtable' flag in favor of .. class: longtable (actually cssclass). If more than 30 lines are found in the table, the 'longtable' mode is automaticaly turned on --- sphinx/directives/other.py | 5 +---- sphinx/writers/latex.py | 7 +++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 85f85f35b..80c88f5fd 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -396,14 +396,11 @@ class TabularColumns(Directive): required_arguments = 1 optional_arguments = 0 final_argument_whitespace = True - option_spec = { - 'longtable': directives.flag, - } + option_spec = {} def run(self): node = addnodes.tabular_col_spec() node['spec'] = self.arguments[0] - node['longtable'] = 'longtable' in self.options return [node] diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 81368d0e8..4cd6070e2 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -589,7 +589,6 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_tabular_col_spec(self, node): self.next_table_colspec = node['spec'] - self.next_table_longtable = node['longtable'] raise nodes.SkipNode def visit_table(self, node): @@ -598,12 +597,14 @@ class LaTeXTranslator(nodes.NodeVisitor): '%s:%s: nested tables are not yet implemented.' % (self.curfilestack[-1], node.line or '')) self.table = Table() + self.table.longtable = 'longtable' in node['classes'] self.tablebody = [] - self.table.longtable = self.next_table_longtable # Redirect body output until table is finished. self._body = self.body self.body = self.tablebody def depart_table(self, node): + if self.table.rowcount > 30: + self.table.longtable = True self.body = self._body if not self.table.longtable and self.table.caption is not None: self.body.append('\n\\begin{threeparttable}\n' @@ -622,6 +623,8 @@ class LaTeXTranslator(nodes.NodeVisitor): colspec = ('p{%.3f\\textwidth}|' % colwidth) * \ self.table.colcount self.body.append('{|' + colspec + '}\n') + elif self.table.longtable: + self.body.append('{|' + ('l|' * self.table.colcount) + '}\n') else: self.body.append('{|' + ('L|' * self.table.colcount) + '}\n') if self.table.longtable and self.table.caption is not None: