aboutsummaryrefslogtreecommitdiffstats
path: root/markdown_extensions/tables.py
diff options
context:
space:
mode:
authorWaylan Limberg <waylan@gmail.com>2008-11-20 19:45:33 -0500
committerWaylan Limberg <waylan@gmail.com>2008-11-20 19:45:33 -0500
commit34666742ee4b5cb03f9a9f6297d5784f553d5346 (patch)
treec9e7ece5ba86bdc3adbf7150c25cd6f9b4ed0bdb /markdown_extensions/tables.py
parent517d38e552e91ebbe527a0286d43dd1daa585bcc (diff)
downloadmarkdown-34666742ee4b5cb03f9a9f6297d5784f553d5346.tar.gz
markdown-34666742ee4b5cb03f9a9f6297d5784f553d5346.tar.bz2
markdown-34666742ee4b5cb03f9a9f6297d5784f553d5346.zip
Moved markdown_extensions/ to markdown/extensions. Markdown is now one package instead of two.
Diffstat (limited to 'markdown_extensions/tables.py')
-rw-r--r--markdown_extensions/tables.py70
1 files changed, 0 insertions, 70 deletions
diff --git a/markdown_extensions/tables.py b/markdown_extensions/tables.py
deleted file mode 100644
index 0e5cd96..0000000
--- a/markdown_extensions/tables.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env python
-
-"""
-Table extension for Python-Markdown
-"""
-
-import markdown
-from markdown import etree
-
-class TablePattern(markdown.Pattern) :
- def __init__ (self, md):
- markdown.Pattern.__init__(self, r'(^|\n)\|([^\n]*)\|')
- self.md = md
-
- def handleMatch(self, m):
-
- # a single line represents a row
- tr = etree.Element('tr')
-
- # chunks between pipes represent cells
-
- for t in m.group(3).split('|'):
-
- if len(t) >= 2 and t.startswith('*') and t.endswith('*'):
- # if a cell is bounded by asterisks, it is a <th>
- td = etree.Element('th')
- t = t[1:-1]
- else:
- # otherwise it is a <td>
- td = etree.Element('td')
-
- # add text ot inline section, later it will be
- # processed by core
-
- td.text = t
- tr.append(td)
- tr.tail = "\n"
-
- return tr
-
-class TableTreeprocessor(markdown.Treeprocessor):
-
- def _findElement(self, element, name):
- result = []
- for child in element:
- if child.tag == name:
- result.append(child)
- result += self._findElement(child, name)
- return result
-
- def run(self, root):
-
- for element in self._findElement(root, "p"):
- for child in element:
- if child.tail:
- element.tag = "table"
- break
-
-
-
-
-class TableExtension(markdown.Extension):
- def extendMarkdown(self, md, md_globals):
- md.inlinePatterns.add('table', TablePattern(md), "<backtick")
- md.treeprocessors.add('table', TableTreeprocessor(), "<prettify")
-
-
-def makeExtension(configs):
- return TableExtension(configs)
-