From: Waylan L. <way...@ic...> - 2019-01-20 20:36:40
|
This was part of the changes <https://python-markdown.github.io/change_log/release-3.0/#homegrown-ordereddict-has-been-replaced-with-a-purpose-built-registry> to version 3.0. You should use deregister <https://python-markdown.github.io/extensions/api/#registry.deregister>: class EscapeHTML(Extension): def extendMarkdown(self, md, md_globals): md.preprocessors.deregister(‘html_block’) md.inlinePatterns.deregister(‘html’) md.inlinePatterns.deregister(‘entity’) Waylan Limberg > On Jan 15, 2019, at 6:58 AM, Dr Rainer Woitok <rai...@gm...> wrote: > > Waylan, > > On Wednesday, 2016-04-06 18:31:57 +0000, you wrote: > >> ... >> If you would like HTML entities to be escaped as well as HTML tags, then you can remove the `entity` inlinePattern. Just add the appropriate line to your Extension class: >> >> class EscapeHtml(Extension): >> def extendMarkdown(self, md, md_globals): >> del md.preprocessors['html_block'] >> del md.inlinePatterns['html'] >> del md.inlinePatterns['entity'] >> >> Hope that helps. > > This was 2.75 years ago and it solved my problem, which was: > >> ... >> On Mar 25, 2016, at 11:57 AM, Dr Rainer Woitok <rai...@gm... <mailto:rai...@gm...>> wrote: >> ... >> $ cat test >> #! /usr/bin/env python >> # -*- coding: iso-8859-1 -*- >> >> import markdown >> from markdown.extensions import Extension >> >> class EscapeHtml(Extension): >> def extendMarkdown(self, md, md_globals): >> del md.preprocessors['html_block'] >> del md.inlinePatterns['html'] >> >> print markdown.markdown('<&>:& becomes &', extensions=[EscapeHtml()]) >> $ ./test >> <p><&>:& becomes &</p> >> $ >> >> However, I would expect the output to be >> >> <p><&>:& becomes &amp;</p> > > More precisely, it at least worked until changeset "81fb14216e8c" (dated > 2018-06-28 23:33:34 +0300) in the source repository. However, after re- > installing Markdown from changeset "596be577c69c" (dated 2018-12-22 15: > 51:30 -0500) and re-running my little test script I'm now again getting > > <p><&>:& becomes &</p> > > What do I have to change this time? > > Sincerely, > Rainer > > > _______________________________________________ > Python-markdown-discuss mailing list > Pyt...@li... <mailto:Pyt...@li...> > https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss <https://lists.sourceforge.net/lists/listinfo/python-markdown-discuss> |