Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve standalone * and _ parsing. #1303

Merged
merged 1 commit into from
Nov 15, 2022
Merged

Conversation

waylan
Copy link
Member

@waylan waylan commented Nov 14, 2022

The NOT_STRONG_RE regex matchs 1, 2, or 3 * or _ which are surrounded by white space to prevent them from being parsed as tokens. However, the surrounding white space should not be consumed by the regex, which is why lookhead and lookbehind assertions are used. As ^ cannot be matched in a lookbehind assertion, it is left outside the assertion, but as it is zero length, that should not matter.

Tests added and/or updated to cover various edge cases. Fixes #1300.

The `NOT_STRONG_RE` regex matchs 1, 2, or 3 * or _ which are surrounded by
white space to prevent them from being parsed as tokens. However, the
surrounding white space should not be consumed by the regex, which is why
lookhead and lookbehind assertions are used. As `^` cannot be matched in a
lookbehind assertion, it is left outside the assertion, but as it is zero
length, that should not matter.

Tests added and/or updated to cover various edge cases. Fixes Python-Markdown#1300.
Comment on lines -77 to +120
'foo * bar *',
'<p>foo * bar *</p>'
'foo *bar *',
'<p>foo *bar *</p>'
Copy link
Member Author

@waylan waylan Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there was no change in behavior for this test. This change ensures that the test is actually testing what it was intended to test. By making the first * not standalone, the only way the test will pass is if the second one is standalone.

@waylan waylan merged commit 939a2fe into Python-Markdown:master Nov 15, 2022
@waylan waylan deleted the 1300 branch November 15, 2022 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stand-alone * or _ lead to incorrect results
2 participants