fix: prevent mixed =/- chars in Setext-style headings (+tests)#1606
fix: prevent mixed =/- chars in Setext-style headings (+tests)#1606Jah-yee wants to merge 1 commit into
Conversation
|
Added 3 test cases in tests/test_syntax/blocks/test_headers.py covering mixed-char rejection (test_setext_mixed_chars_not_h1, test_setext_mixed_chars_not_h2, test_setext_mixed_multiple_chars). All tests pass. The fix is ready for review! |
e3f98c7 to
be69b20
Compare
|
Thanks for your submission. There are two failing tests that need addressed.
Please do not close this issue and open a new one. Also, do not replace your commit and force-push. Instead, add additional commits to this issue to make the changes while preserving the existing commits you already made. Please review the Contributing Guide for more information. If anything is still unclear, please feel free to ask. |
…01) and changelog entry for Python-Markdown#1606
9d47bfc to
5e183a3
Compare
|
I addressed both failing tests:
CI should now pass. Please re-review when you have a chance. |
|
|
||
| # Detect Setext-style header. Must be first 2 lines of block. | ||
| RE = re.compile(r'^.*?\n[=-]+[ ]*(\n|$)', re.MULTILINE) | ||
| RE = re.compile(r'^.*?\n(?:[=]+|[-]+)[ ]*(\n|$)', re.MULTILINE) |
There was a problem hiding this comment.
I think [ and ] are not needed anymore, since you allow 1 character instead of 2:
| RE = re.compile(r'^.*?\n(?:[=]+|[-]+)[ ]*(\n|$)', re.MULTILINE) | |
| RE = re.compile(r'^.*?\n(?:=+|-+)[ ]*(\n|$)', re.MULTILINE) |
There was a problem hiding this comment.
Good catch. I missed this. Thank you.
5e183a3 to
65666a6
Compare
The character class form [=]+ and [=]+ are equivalent to =+ and =+ respectively, but the bare form is cleaner per mitya57's review suggestion on PR Python-Markdown#1606.
|
✅ Both issues addressed in pushed commit
|
The character class form [=]+ and [=]+ are equivalent to =+ and =+ respectively, but the bare form is cleaner per mitya57's review suggestion on PR Python-Markdown#1606.
dd2fac0 to
a67046c
Compare
a67046c to
1e53719
Compare
|
Thanks for the review. I've squashed the commits into one: |
Summary
This PR fixes issue #1604 - mixed =/- characters in Setext-style headers were incorrectly matched.
Changes
[=-]+to(?:[=]+|[-]+)to match only homogeneous runsTests Added
test_setext_mixed_chars_not_h1:=-should not form an H1test_setext_mixed_chars_not_h2:-=should not form an H2test_setext_mixed_multiple_chars: Mixed runs are not valid headersCloses #1604