getpelican / pelican

Static site generator that supports Markdown and reST syntax. Powered by Python.
https://getpelican.com
GNU Affero General Public License v3.0
12.57k stars 1.81k forks source link

Ampersands don't seem to be escaped in text in markdown #3285

Closed mikekreuzer closed 9 months ago

mikekreuzer commented 9 months ago

Issue

Python-Markdown gives me:

import markdown
md = markdown.Markdown()
md.convert('this & that')            # gives <p>this &amp; that</p>

But on a pelican page the same markdown gives me:

<p>this & that</p>

Unescaped

justinmayer commented 9 months ago

I can't reproduce this. On my workstation, I get the following in my generated output:

<p>this <span class="amp">&amp;</span> that</p>
MinchinWeb commented 9 months ago

I can't reproduce this. On my workstation, I get the following in my generated output:

<p>this <span class="amp">&amp;</span> that</p>

Do you have typogrify installed/active? (I think that's where the <span> comes from...)

avaris commented 9 months ago

Do you have typogrify installed/active? (I think that's where the <span> comes from...)

<span> yes from typogrify, but escaped &amp; is not. So I cannot replicate this either, here is without typogrify:

$ cat content/articles/article.md
title: test
date: 01-01-2023

this & that
$ cat pelicanconf.py
SITEURL = 'https://example.com'
TIMEZONE = 'Europe/Paris'

TYPOGRIFY = False
$ pelican content -s pelicanconf.py
Done: Processed 1 article, 0 drafts, 0 hidden articles, 0 pages, 0 hidden pages and 0 draft pages in 0.09 seconds.
$ grep that output/test.html
        <meta name="description" content="this & that" />
</footer><!-- /.post-info -->      <p>this &amp; that</p>
mikekreuzer commented 9 months ago

I am an idiot - profuse apologies.

PyCharm & Safari were both unescaping the text again when they showed it to me, even in the editor, I don't know why they'd do that, it was only when I happened to open a file in VS Code that I saw it was indeed there all along.

Sorry, sorry, sorry.

MinchinWeb commented 9 months ago

Please let us laugh with you ;) Glad you figured it out!