diff options
-rwxr-xr-x | markdown.py | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | mdx_codehilite.py | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | mdx_footnotes.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | mdx_headerid.py | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | mdx_imagelinks.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | mdx_rss.py | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | mdx_wikilink.py | 17 |
7 files changed, 31 insertions, 20 deletions
diff --git a/markdown.py b/markdown.py index 12fd70d..b5903f5 100755 --- a/markdown.py +++ b/markdown.py @@ -1203,6 +1203,8 @@ class Markdown: ] self.inlineStash = InlineStash() + + self._inlineOperationID = None self.registerExtensions(extensions = extensions, configs = extension_configs) @@ -1630,6 +1632,7 @@ class Markdown: """ startIndex = 0 + while patternIndex < len(self.inlinePatterns): data, matched, startIndex = self._applyInline( @@ -1637,7 +1640,6 @@ class Markdown: data, patternIndex, startIndex) if not matched: patternIndex += 1 - return data def _applyInline(self, pattern, data, patternIndex, startIndex=0): @@ -1656,14 +1658,12 @@ class Markdown: Returns: String with placeholders. """ - match = pattern.getCompiledRegExp().match(data[startIndex:]) leftData = data[:startIndex] if not match: return data, False, 0 - node = pattern.handleMatch(match) if node is None: @@ -1676,7 +1676,7 @@ class Markdown: if not isstr(node): if child.text: child.text = self._handleInline(child.text, - patternIndex) + patternIndex + 1) if child.tail: child.tail = self._handleInline(child.tail, patternIndex) diff --git a/mdx_codehilite.py b/mdx_codehilite.py index 6f81598..73c1a79 100644..100755 --- a/mdx_codehilite.py +++ b/mdx_codehilite.py @@ -80,10 +80,11 @@ class CodeHilite: except ImportError: # just escape and pass through txt = self._escape(self.src) - if num: + '''if num: txt = self._number(txt) else : - txt = '<div class="codehilite"><pre>%s</pre></div>\n'% txt + txt = '<div class="codehilite"><pre>%s</pre></div>\n'% txt''' + txt = self._number(txt) return txt else: try: @@ -204,7 +205,10 @@ class CodeHiliteExtention(markdown.Extension): text = "\n".join(detabbed).rstrip()+"\n" code = CodeHilite(text, linenos=self.config['force_linenos'][0]) placeholder = md.htmlStash.store(code.hilite(), safe=True) - parent_elem.appendChild(md.doc.createTextNode(placeholder)) + if parent_elem.text: + parent_elem.text += placeholder + else: + parent_elem.text = placeholder md._processSection(parent_elem, theRest, inList) md._processCodeBlock = _hiliteCodeBlock diff --git a/mdx_footnotes.py b/mdx_footnotes.py index b46efbb..b46efbb 100644..100755 --- a/mdx_footnotes.py +++ b/mdx_footnotes.py diff --git a/mdx_headerid.py b/mdx_headerid.py index 2e658cd..2360071 100644..100755 --- a/mdx_headerid.py +++ b/mdx_headerid.py @@ -68,6 +68,7 @@ Dependencies: """ import markdown +from markdown import etree import re from string import ascii_lowercase, digits, punctuation @@ -106,15 +107,16 @@ class HeaderIdExtension (markdown.Extension) : if m : start_level, force_id = _get_meta() level = len(m.group(1)) + start_level - if level > 6: level = 6 - h = md.doc.createElement("h%d" % level) - parent_elem.appendChild(h) - for item in md._handleInline(m.group(2).strip()) : - h.appendChild(item) + if level > 6: + level = 6 + h = etree.Element("h%d" % level) + parent_elem.append(h) + inline = etree.SubElement(h, "inline") + inline.text = m.group(2).strip() if m.group(3) : - h.setAttribute('id', _unique_id(m.group(3))) + h.set('id', _unique_id(m.group(3))) elif force_id: - h.setAttribute('id', _create_id(m.group(2).strip())) + h.set('id', _create_id(m.group(2).strip())) else : message(CRITICAL, "We've got a problem header!") diff --git a/mdx_imagelinks.py b/mdx_imagelinks.py index e545b24..e545b24 100644..100755 --- a/mdx_imagelinks.py +++ b/mdx_imagelinks.py diff --git a/mdx_rss.py b/mdx_rss.py index b88b9b5..b88b9b5 100644..100755 --- a/mdx_rss.py +++ b/mdx_rss.py diff --git a/mdx_wikilink.py b/mdx_wikilink.py index 46d6c3f..47037a6 100644..100755 --- a/mdx_wikilink.py +++ b/mdx_wikilink.py @@ -69,6 +69,7 @@ Dependencies: ''' import markdown +from markdown import etree class WikiLinkExtension (markdown.Extension) : def __init__(self, configs): @@ -91,24 +92,25 @@ class WikiLinkExtension (markdown.Extension) : WIKILINK_PATTERN = WikiLinks(WIKILINK_RE, self.config) WIKILINK_PATTERN.md = md md.inlinePatterns.append(WIKILINK_PATTERN) + class WikiLinks (markdown.BasePattern) : def __init__(self, pattern, config): markdown.BasePattern.__init__(self, pattern) self.config = config - def handleMatch(self, m, doc) : + def handleMatch(self, m): if m.group('escape') == '\\': - a = doc.createTextNode(m.group('camelcase')) + a = m.group('camelcase') else: base_url, end_url, html_class = self._getMeta() url = '%s%s%s'% (base_url, m.group('camelcase'), end_url) label = m.group('camelcase').replace('_', ' ') - a = doc.createElement('a') - a.appendChild(doc.createTextNode(label)) - a.setAttribute('href', url) + a = etree.Element('a') + a.text = label + a.set('href', url) if html_class: - a.setAttribute('class', html_class) + a.set('class', html_class) return a def _getMeta(self): @@ -124,6 +126,9 @@ class WikiLinks (markdown.BasePattern) : if self.md.Meta.has_key('wiki_html_class'): html_class = self.md.Meta['wiki_html_class'][0] return base_url, end_url, html_class + + def type(self): + return "WLink" def makeExtension(configs=None) : |