summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSewci0 <seweryn.ch@gmail.com>2016-11-11 01:27:02 +0100
committerSewci0 <seweryn.ch@gmail.com>2016-11-11 01:27:02 +0100
commit1e8f7d6d720ba1763cf43f4b21e75114b372c436 (patch)
treec9c1f6c720db5a1b6df2da22c17853740f8056ca
parent40b7a5453ac961b1fdb094481afd4a6c1138bc46 (diff)
downloadpython-prettytable-ptable-1e8f7d6d720ba1763cf43f4b21e75114b372c436.tar.gz
Added <tbody> and <thead> tags
-rw-r--r--prettytable/prettytable.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/prettytable/prettytable.py b/prettytable/prettytable.py
index 3b9bf27..3dd2450 100644
--- a/prettytable/prettytable.py
+++ b/prettytable/prettytable.py
@@ -1452,14 +1452,17 @@ class PrettyTable(object):
# Headers
if options["header"]:
+ lines.append("<thead>")
lines.append(" <tr>")
for field in self._field_names:
if options["fields"] and field not in options["fields"]:
continue
lines.append(" <th>%s</th>" % escape(field).replace("\n", linebreak))
lines.append(" </tr>")
+ lines.append("</thead>")
# Data
+ lines.append("<tbody>")
rows = self._get_rows(options)
formatted_rows = self._format_rows(rows, options)
for row in formatted_rows:
@@ -1469,7 +1472,7 @@ class PrettyTable(object):
continue
lines.append(" <td>%s</td>" % escape(datum).replace("\n", linebreak))
lines.append(" </tr>")
-
+ lines.append("</tbody>")
lines.append("</table>")
return self._unicode("\n").join(lines)
@@ -1516,6 +1519,7 @@ class PrettyTable(object):
# Headers
if options["header"]:
+ lines.append("<thead>")
lines.append(" <tr>")
for field in self._field_names:
if options["fields"] and field not in options["fields"]:
@@ -1524,8 +1528,10 @@ class PrettyTable(object):
" <th style=\"padding-left: %dem; padding-right: %dem; text-align: center\">%s</th>" % (
lpad, rpad, escape(field).replace("\n", linebreak)))
lines.append(" </tr>")
+ lines.append("</thead>")
# Data
+ lines.append("<tbody>")
rows = self._get_rows(options)
formatted_rows = self._format_rows(rows, options)
aligns = []
@@ -1542,8 +1548,10 @@ class PrettyTable(object):
" <td style=\"padding-left: %dem; padding-right: %dem; text-align: %s; vertical-align: %s\">%s</td>" % (
lpad, rpad, align, valign, escape(datum).replace("\n", linebreak)))
lines.append(" </tr>")
+ lines.append("</tbody>")
lines.append("</table>")
+
return self._unicode("\n").join(lines)