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

More conservative strong/em markdown matcher #352

Merged
merged 1 commit into from May 6, 2024

Conversation

mrdomino
Copy link
Contributor

Both matchers are now constrained so that they will only be transformed if the left-hand characters are the start of the text or preceeded by whitespace, and the right-hand characters are the end of the text or followed by whitespace or a punctuation mark.

This misses some cases, e.g. emphasis inside of parantheticals, but has better behavior with e.g. underscores in function names outside of code blocks.

Fixes #317.

Both matchers are now constrained so that they will only be transformed
if the left-hand characters are the start of the text or preceeded by
whitespace, and the right-hand characters are the end of the text or
followed by whitespace or a punctuation mark.

This misses some cases, e.g. emphasis inside of parantheticals, but has
better behavior with e.g. underscores in function names outside of code
blocks.

Fixes Mozilla-Ocho#317.
Copy link

@evelynmitchell evelynmitchell left a comment

Choose a reason for hiding this comment

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

Can you explain in a bit more detail what you intend with the change from \1 to \2 in lines 1124 and 1125?

Thanks!

@mrdomino
Copy link
Contributor Author

It's different regex capture groups. \1 is a backreference (it says "match another instance of whatever you matched in group 1 here") and $2 is saying "put whatever you found in group 2 here" in the replacement.

In the old regex, group 1 was the opening delimiter to be matched against when searching for a closing delimiter, and group 2 was the text between the pair of delimiters. In the new regex, group 1 is the opening whitespace character, group 2 is the opening delimiter, group 3 is the text between the delimiter pair, and group 4 is the closing whitespace/punctuation. So \2 is now the way to refer to the opening delimiter for the backreference, and $1 and $4 need to be included in the replacement.

@jart jart force-pushed the main branch 2 times, most recently from 622924c to 9cf7363 Compare April 30, 2024 03:35
Copy link
Collaborator

@jart jart left a comment

Choose a reason for hiding this comment

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

Thank you!

@jart jart merged commit eecbf89 into Mozilla-Ocho:main May 6, 2024
@mrdomino mrdomino deleted the emfix branch May 6, 2024 18:37
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.

Web UI mis-interprets symbols in code elements as Markdown formatting
3 participants