Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

2.5.5 regression: strong emphasis adjacent to word/CJK chars fails when content starts or ends with punctuation

Aperta
#688 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia con Markdown._do_italics_and_bold() e GFMItalicAndBoldProcessor, confrontando il percorso basato sulle espressioni regolari della versione 2.5.4 con il percorso del processore della versione 2.5.5. Esegui le riproduzioni minima e più lunga su entrambe le versioni, quindi aggiungi una copertura di regressione che dimostri che il testo alfanumerico o CJK adiacente con punteggiatura produce lo stesso HTML di enfasi forte della versione 2.5.4.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug

Summary

After upgrading from markdown2 2.5.4 to 2.5.5, strong emphasis sometimes stops parsing when all of these are true:

  • the **...** span is adjacent to alphanumeric or CJK text without surrounding spaces
  • the emphasized content starts or ends with punctuation, for example Chinese quotes or parentheses

On 2.5.4 these cases render correctly. On 2.5.5 the parser leaves literal ** in the output, and in longer inputs it can also emit malformed mixed HTML.

This reproduces with the default parser configuration, no extras required.

Related to #679 because it also looks like an emphasis-regression in the recent parser changes, but this one reproduces without middle-word-em and with plain markdown2.markdown(...).

Minimal repro

import markdown2

cases = [
    'a**“b”**c',
    '**“b”**c',
    'a**(b)**c',
]

print('version:', markdown2.__version__)
for text in cases:
    print('INPUT :', text)
    print('OUTPUT:', markdown2.markdown(text).strip())
    print()
2.5.4
<p>a<strong>“b”</strong>c</p>
<p><strong>“b”</strong>c</p>
<p>a<strong>(b)</strong>c</p>
2.5.5
<p>a**“b”**c</p>
<p>**“b”**c</p>
<p>a**(b)**c</p>

Longer repro that produces malformed mixed HTML

import markdown2

text = '*   **示例**:系统会使用**(方案A)**或**(方案B)**进行处理。'
print(markdown2.markdown(text))
2.5.4
<ul>
<li><strong>示例</strong>:系统会使用<strong>(方案A)</strong>或<strong>(方案B)</strong>进行处理。</li>
</ul>
2.5.5
<ul>
<li><strong>示例</strong>:系统会使用**(方案A)<strong>或</strong>(方案B)**进行处理。</li>
</ul>

Suspected regression window

Looking at the source, Markdown._do_italics_and_bold() changed between these versions:

2.5.4
text = self._strong_re.sub(r"<strong>\\2</strong>", text)
text = self._em_re.sub(r"<em>\\2</em>", text)
2.5.5
if not self._iab_processor:
    self._iab_processor = GFMItalicAndBoldProcessor(self, None)
if self._iab_processor.test(text):
    text = self._iab_processor.run(text)

So this looks related to the switch to GFMItalicAndBoldProcessor as the default implementation for _do_italics_and_bold().

Environment

  • Python: 3.14.0
  • markdown2: 2.5.4 vs 2.5.5
  • OS: Windows 11
Lingua principale
Python
Stelle
2.8k
Fork
459
Merge medio
2g 19h
PR unite (30g)
4

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di trentm/python-markdown2

Tutte le issue di trentm/python-markdown2

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.