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

Offen
#756 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 3 Tagen

@awais-ur-rehman arbeitet bereits daran.

Seit 30.10.2026.

  • #757 von @awais-ur-rehman — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
python
Bereich
backend

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
2.8k
Forks
477
Ø Merge
4 T. 10 Std.
Gemergte PRs (30 T.)
12

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus trentm/python-markdown2

Alle Issues in trentm/python-markdown2

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.