From 7b37146f0da1f7e46f25d58ae5bcc9d0289e202b Mon Sep 17 00:00:00 2001 From: grubert Date: Fri, 25 May 2007 09:34:16 +0000 Subject: [PATCH] Add table stubs support (boldfont). git-svn-id: https://docutils.svn.sourceforge.net/svnroot/docutils/trunk/docutils@5141 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- HISTORY.txt | 1 + docutils/writers/latex2e/__init__.py | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/HISTORY.txt b/HISTORY.txt index c402e189d..e26b884b6 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -116,6 +116,7 @@ Changes Since 0.4 * docutils/writers/latex2e/__init__.py: + - Add table stubs support (boldfont). - Add assemble_parts to writer. - Add simply support for nested tables. - Fix verbatim in tables if use-verbatim-when-possible. diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py index cbded8370..d58c9c5eb 100644 --- a/docutils/writers/latex2e/__init__.py +++ b/docutils/writers/latex2e/__init__.py @@ -384,6 +384,7 @@ class Table: self._attrs = {} self._col_width = [] self._rowspan = [] + self.stubs = [] def open(self): self._open = 1 @@ -396,6 +397,7 @@ class Table: self._col_specs = None self.caption = None self._attrs = {} + self.stubs = [] def is_open(self): return self._open def set_table_style(self, table_style): @@ -431,8 +433,10 @@ class Table: lines = '\\hline\n' return '%s\\end{%s}' % (line,self._latex_type) - def visit_colspec(self,node): + def visit_colspec(self, node): self._col_specs.append(node) + # "stubs" list is an attribute of the tgroup element: + self.stubs.append(node.attributes.get('stub')) def get_colspecs(self): """ @@ -535,6 +539,10 @@ class Table: return self._cell_in_row def visit_entry(self): self._cell_in_row += 1 + def is_stub_column(self): + if len(self.stubs) >= self._cell_in_row: + return self.stubs[self._cell_in_row-1] + return False class LaTeXTranslator(nodes.NodeVisitor): @@ -1318,6 +1326,9 @@ class LaTeXTranslator(nodes.NodeVisitor): if isinstance(node.parent.parent, nodes.thead): self.body.append('\\textbf{') self.context.append('}') + elif self.active_table.is_stub_column(): + self.body.append('\\textbf{') + self.context.append('}') else: self.context.append('') -- 2.11.4.GIT