From: Waylan L. <wa...@gm...> - 2010-05-05 01:56:19
|
On Tue, May 4, 2010 at 8:08 PM, Tom Ritter <to...@ri...> wrote: > This isn't the best solution, but I disable images by using this extension: > > import markdown > from markdown import etree > > class DisableImagesExtension(markdown.Extension): > def extendMarkdown(self, md, md_globals): > md.treeprocessors.add('disableImages', DisableImages(md), '_end') > > class DisableImages(markdown.treeprocessors.Treeprocessor): > def descendRemove(self, element): > for i in element: > if i.tag == 'img': > element.remove(i) > else: > self.descendRemove(i) > def run(self, root): > self.descendRemove(root) > return root > How about this: import markdown class DisableImagesExtension(markdown.Extension): def extendMarkdown(self, md, md_globals): del md.inlinePatterns["link"] del md.inlinePatterns["image_reference"] That's it. The image syntax will not never be parsed - which is more of a markdown type behavior. Any unrecognized syntax should go through unaltered. The names of all the patterns and processors can be found where they are added in the` Markdown.__init__` method of the `markdown/__init__.py` file. -- ---- \X/ /-\ `/ |_ /-\ |\| Waylan Limberg |