/
usr
/
lib
/
python2.6
/
site-packages
/
markdown
/
extensions
/
/usr/lib/python2.6/site-packages/markdown/extensions
mkdir
upload
Name
Size
Mode
Actions
abbr.py
2899
0644
edit
dl
rm
abbr.pyc
4294
0644
edit
dl
rm
abbr.pyo
4294
0644
edit
dl
rm
codehilite.py
7673
0644
edit
dl
rm
codehilite.pyc
8129
0644
edit
dl
rm
codehilite.pyo
8129
0644
edit
dl
rm
def_list.py
3170
0644
edit
dl
rm
def_list.pyc
4047
0644
edit
dl
rm
def_list.pyo
4047
0644
edit
dl
rm
extra.py
1739
0644
edit
dl
rm
extra.pyc
2323
0644
edit
dl
rm
extra.pyo
2323
0644
edit
dl
rm
fenced_code.py
3423
0644
edit
dl
rm
fenced_code.pyc
4371
0644
edit
dl
rm
fenced_code.pyo
4371
0644
edit
dl
rm
footnotes.py
10055
0644
edit
dl
rm
footnotes.pyc
11433
0644
edit
dl
rm
footnotes.pyo
11433
0644
edit
dl
rm
headerid.py
6326
0644
edit
dl
rm
headerid.pyc
7470
0644
edit
dl
rm
headerid.pyo
7470
0644
edit
dl
rm
html_tidy.py
2071
0644
edit
dl
rm
html_tidy.pyc
2756
0644
edit
dl
rm
html_tidy.pyo
2756
0644
edit
dl
rm
imagelinks.py
3491
0644
edit
dl
rm
imagelinks.pyc
3311
0644
edit
dl
rm
imagelinks.pyo
3311
0644
edit
dl
rm
meta.py
2590
0644
edit
dl
rm
meta.pyc
3275
0644
edit
dl
rm
meta.pyo
3275
0644
edit
dl
rm
rss.py
3693
0644
edit
dl
rm
rss.pyc
4337
0644
edit
dl
rm
rss.pyo
4337
0644
edit
dl
rm
tables.py
3079
0644
edit
dl
rm
tables.pyc
3877
0644
edit
dl
rm
tables.pyo
3877
0644
edit
dl
rm
toc.py
5098
0644
edit
dl
rm
toc.pyc
4466
0644
edit
dl
rm
toc.pyo
4466
0644
edit
dl
rm
wikilinks.py
5292
0644
edit
dl
rm
wikilinks.pyc
6281
0644
edit
dl
rm
wikilinks.pyo
6281
0644
edit
dl
rm
__init__.py
0
0644
edit
dl
rm
__init__.pyc
151
0644
edit
dl
rm
__init__.pyo
151
0644
edit
dl
rm
Edit:
/usr/lib/python2.6/site-packages/markdown/extensions/def_list.py
(3170B)
""" Definition List Extension for Python-Markdown ============================================= Added parsing of Definition Lists to Python-Markdown. A simple example: Apple : Pomaceous fruit of plants of the genus Malus in the family Rosaceae. : An american computer company. Orange : The fruit of an evergreen tree of the genus Citrus. Copyright 2008 - [Waylan Limberg](http://achinghead.com) """ import markdown, re from markdown import etree class DefListProcessor(markdown.blockprocessors.BlockProcessor): """ Process Definition Lists. """ RE = re.compile(r'(^|\n)[ ]{0,3}:[ ]{1,3}(.*?)(\n|$)') def test(self, parent, block): return bool(self.RE.search(block)) def run(self, parent, blocks): block = blocks.pop(0) m = self.RE.search(block) terms = [l.strip() for l in block[:m.start()].split('\n') if l.strip()] d, theRest = self.detab(block[m.end():]) if d: d = '%s\n%s' % (m.group(2), d) else: d = m.group(2) #import ipdb; ipdb.set_trace() sibling = self.lastChild(parent) if not terms and sibling.tag == 'p': # The previous paragraph contains the terms state = 'looselist' terms = sibling.text.split('\n') parent.remove(sibling) # Aquire new sibling sibling = self.lastChild(parent) else: state = 'list' if sibling and sibling.tag == 'dl': # This is another item on an existing list dl = sibling if len(dl) and dl[-1].tag == 'dd' and len(dl[-1]): state = 'looselist' else: # This is a new list dl = etree.SubElement(parent, 'dl') # Add terms for term in terms: dt = etree.SubElement(dl, 'dt') dt.text = term # Add definition self.parser.state.set(state) dd = etree.SubElement(dl, 'dd') self.parser.parseBlocks(dd, [d]) self.parser.state.reset() if theRest: blocks.insert(0, theRest) class DefListIndentProcessor(markdown.blockprocessors.ListIndentProcessor): """ Process indented children of definition list items. """ ITEM_TYPES = ['dd'] LIST_TYPES = ['dl'] def create_item(parent, block): """ Create a new dd and parse the block with it as the parent. """ dd = markdown.etree.SubElement(parent, 'dd') self.parser.parseBlocks(dd, [block]) class DefListExtension(markdown.Extension): """ Add definition lists to Markdown. """ def extendMarkdown(self, md, md_globals): """ Add an instance of DefListProcessor to BlockParser. """ md.parser.blockprocessors.add('defindent', DefListIndentProcessor(md.parser), '>indent') md.parser.blockprocessors.add('deflist', DefListProcessor(md.parser), '>ulist') def makeExtension(configs={}): return DefListExtension(configs=configs)
Save
cmd:
run