Code spans that wrap onto the next line are no longer recognised (regression from the #702 fix)

Ouverte
#756 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 3 jours

@awais-ur-rehman y travaille déjà.

Depuis le 30/10/2026.

  • #757 par @awais-ur-rehman — ouverte

Évaluation

Difficulté
4/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
python
Domaine
backend

Piste de recherche

Start by reading _code_span_re and the #702 change that removed re.S, then trace the related safe mode handling described in the issue. Check how code spans with line endings are parsed and how safe_mode="escape" and safe_mode="replace" behave. Done means wrapped code spans are recognized while the #702 safety handling remains correct.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Since 69635a9 (the fix for #702), a code span that wraps onto the next line is no longer recognised. This is common in hard-wrapped docs:

>>> markdown2.markdown("Call the `foo\nbar()` function.")
'<p>Call the `foo\nbar()` function.</p>\n'

Before that commit, the same input gave:

'<p>Call the <code>foo\nbar()</code> function.</p>\n'

The commit removed re.S from _code_span_re, so . in the pattern no longer matches the line ending. As far as I can tell this hasn't been released yet (it's after 2.5.5), so it might be worth sorting out before the next release.

Code spans can contain line endings in Markdown.pl and in CommonMark (spec, 6.1, where line endings are turned into spaces), so this looks unintended.

Simply putting re.S back doesn't seem right either. It doesn't bring back an executable XSS (the #702 example comes out escaped in safe_mode="escape"), but in safe_mode="replace" the tag is escaped instead of replaced. So the fix probably needs to happen together with the #702 handling. I didn't want to guess at the intended approach, so I'm opening this as an issue instead of a PR.

Langage dominant
Python
Étoiles
2.8k
Forks
477
Merge moyen
4 j 10 h
PR mergées (30 j)
12

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de trentm/python-markdown2

Toutes les issues de trentm/python-markdown2

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.