Permalink
Browse files

Table converter: heading cells are bold. #6

  • Loading branch information...
1 parent 6ec357b commit 9e488f90def6c7dafe155e0ae616fa5d9cc9f796 @jone jone committed May 2, 2012
@@ -584,7 +584,7 @@ def render_content(self):
if 'scriptsize' in self.get_css_classes():
latex = r'\scriptsize %s' % latex
- if 'bold' in self.get_css_classes():
+ if 'bold' in self.get_css_classes() or self.is_head_cell():
latex = r'\textbf{%s}' % latex
if 'indent2' in self.get_css_classes():
@@ -598,7 +598,8 @@ def is_head_cell(self):
if 'thead' in [p.tagName.lower() for p in self.get_parent_nodes()]:
# cell is within a <thead>
return True
- if self.dom_cell.tagName.lower() == 'th':
+
+ elif self.dom_cell.tagName.lower() == 'th':
# cell is a <th>
return True
else:
@@ -52,7 +52,7 @@ def test_table_converted(self):
latex = '\n'.join((
r'\begin{tabular}{l}',
- r'\multicolumn{1}{l}{My Head} \\',
+ r'\multicolumn{1}{l}{\textbf{My Head}} \\',
r'\multicolumn{1}{l}{My Body} \\',
r'\end{tabular}',
r''))
@@ -82,7 +82,8 @@ def test_headings(self):
latex = '\n'.join((
r'\begin{tabular}{ll}',
- r'\multicolumn{1}{l}{headA} & \multicolumn{1}{l}{headB} \\',
+ r'\multicolumn{1}{l}{\textbf{headA}} & ' + \
+ r'\multicolumn{1}{l}{\textbf{headB}} \\',
r'\multicolumn{1}{l}{1A} & \multicolumn{1}{l}{1B} \\',
r'\multicolumn{1}{l}{2A} & \multicolumn{1}{l}{2B} \\',
r'\end{tabular}',
@@ -648,8 +649,8 @@ def test_simple_grid_css_class(self):
r'\begin{tabular}{|l|l|}',
r'\hline',
- r'\multicolumn{1}{|l}{heading A} & ' + \
- r'\multicolumn{1}{|l|}{heading B} \\',
+ r'\multicolumn{1}{|l}{\textbf{heading A}} & ' + \
+ r'\multicolumn{1}{|l|}{\textbf{heading B}} \\',
r'\hline',
r'\multicolumn{1}{|l}{content 1A} & ' + \
@@ -697,7 +698,7 @@ def test_complex_grid_css_class(self):
'p{0.25\linewidth}|}',
r'\hline',
- r'\multicolumn{3}{|p{1.0\linewidth}|}{heading} \\',
+ r'\multicolumn{3}{|p{1.0\linewidth}|}{\textbf{heading}} \\',
r'\hline',
r'\multicolumn{1}{|p{0.5\linewidth}|}{content 1A} & ' + \
@@ -747,7 +748,7 @@ def test_listing_css_class(self):
'p{0.25\linewidth}}',
r'\hline',
- r'\multicolumn{3}{p{1.0\linewidth}}{heading} \\',
+ r'\multicolumn{3}{p{1.0\linewidth}}{\textbf{heading}} \\',
r'\hline',
r'\multicolumn{1}{p{0.5\linewidth}}{content 1A} & ' + \
@@ -769,14 +770,12 @@ def test_listing_css_class(self):
def test_border_classes(self):
html = '\n'.join((
r'<table class="no-page-break">',
- r' <thead>',
+ r' <tbody>',
r' <tr>',
- r' <th class="border-right">A1</th>',
- r' <th class="border-top">B1</th>',
- r' <th class="border-left border-bottom">C1</th>',
+ r' <td class="border-right">A1</td>',
+ r' <td class="border-top">B1</td>',
+ r' <td class="border-left border-bottom">C1</td>',
r' </tr>',
- r' </thead>',
- r' <tbody>',
r' <tr>',
r' <td class="border-right">A2</td>',
r' <td class="border-top border-bottom">B2</td>',

0 comments on commit 9e488f9

Please sign in to comment.