From 3680ed6b9c63d8a0a04b4925e42d1b0243521535 Mon Sep 17 00:00:00 2001 From: "buaa.byl" Date: Fri, 5 Aug 2016 13:40:24 +0800 Subject: [PATCH] Add css_class config to extensions/tables.py --- markdown/extensions/tables.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/markdown/extensions/tables.py b/markdown/extensions/tables.py index a19018edf..720b3d9ad 100644 --- a/markdown/extensions/tables.py +++ b/markdown/extensions/tables.py @@ -55,6 +55,7 @@ def run(self, parent, blocks): align.append(None) # Build table table = etree.SubElement(parent, 'table') + table.set('class', self.config['css_class']) thead = etree.SubElement(table, 'thead') self._build_row(header, thead, align, border) tbody = etree.SubElement(table, 'tbody') @@ -134,12 +135,18 @@ def _row_has_unpaired_backticks(self, row): class TableExtension(Extension): """ Add tables to Markdown. """ + def __init__(self, *args, **kwargs): + self.config = { + 'css_class': ['mdtable', 'Set class name for table'] + } + super(TableExtension, self).__init__(*args, **kwargs) + def extendMarkdown(self, md, md_globals): """ Add an instance of TableProcessor to BlockParser. """ - md.parser.blockprocessors.add('table', - TableProcessor(md.parser), - '