Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions markdown/extensions/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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),
'<hashheader')

tabparser = TableProcessor(md.parser)
tabparser.config = self.getConfigs()
md.parser.blockprocessors.add('table', tabparser, '<hashheader')

def makeExtension(*args, **kwargs):
return TableExtension(*args, **kwargs)