From: Waylan L. <way...@ic...> - 2019-01-31 00:29:13
|
Ah, I see your problem. The change was introduced in #670 <https://github.com/Python-Markdown/markdown/pull/670>. The thinking behind that change was that we should only escape things which have not already been escaped. Of course, `&` is already an HTML entity so it is escaped and should not be escaped a second time. However, the actual escaping happens in the serializer, not in the `entity` inline pattern. Therefore the behavior of the serializer was changed to never escape `@amp;. Removing the inline pattern has no effect on this behavior. I do not see any good reason to alter the current behavior of the serializer either. It’s not clear to me how you should proceed. Although, I did question the method we used to accomplish the change in #670 (as you can see in the comments there). Perhaps there is another way we could accomplish the same effect that would better meet your needs as well. I would suggest opening a new issue in GitHub to discuss any possible future changes to the code. 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> |