2.5.5 regression: strong emphasis adjacent to word/CJK chars fails when content starts or ends with punctuation
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Bắt đầu với Markdown._do_italics_and_bold() và GFMItalicAndBoldProcessor, so sánh đường dẫn biểu thức chính quy của 2.5.4 với đường dẫn bộ xử lý của 2.5.5. Chạy các bản tái hiện tối thiểu và dài hơn trên cả hai phiên bản, sau đó thêm phạm vi kiểm thử hồi quy cho thấy văn bản chữ-số hoặc CJK liền kề có dấu câu được kết xuất thành cùng một HTML nhấn mạnh mạnh như trong 2.5.4.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 2.8k
- Fork
- 459
- Merge trung bình
- 2 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 4
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của trentm/python-markdown2
-
Add py.typed marker Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
trentm/python-markdown2#696 ·
-
More XSS's in safe mode Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
trentm/python-markdown2#726 ·
-
Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
trentm/python-markdown2#707 ·
-
Bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
trentm/python-markdown2#679 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
trentm/python-markdown2#635 · 2 bình luận ·
Tất cả issue của trentm/python-markdown2
Issue tương tự
-
agent-ready documentation needs-triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
-
Add https://search.jeremyh.xyz/ Đang mởinstance instance add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
searxng/searx-instances#939 · 1 bình luận ·
-
area-deployment area-integrations triage:bot-seen
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100