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

Update italic highlighting rules to avoid intra word highlights in Markdown Mode. #4358 #4361

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

RickStrahl
Copy link
Contributor

@RickStrahl RickStrahl commented Aug 15, 2020

*Issue #4358

This address italic highlighting in Markdown Syntax.

Description of changes:

Changes the regex to check for word boundaries or beginning/end of line endings to avoid intra-word highlighting of italic text.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Scenarios :

*asddasd*

asdasd_asdasd_asdasdasd

asdasd *asdasd asd* asdasdasd and _asdadsasd_ asdasd


**These shouldn't hightlight**:

adsadas_asdasd_asdddasd_asdddas_adsasd _asdddasdddasd_asdddas_asdasdas_asdd 

**Underlines too**
asddasd*asdasd*asdasdasd*asdasdasd*asd* asddasddasddasdasdasd* *asdds* asdd

**Beginning of line:**

*asddasd* asdasd 

**Mix and Match:**

_asdasd asddasd_  asdasdasd _asddasd_ asdddasddd *adsasd*


*end of file*

Ironically, GitHub has the exact same issues as it highlights the text above incorrectly too 😄.

@RickStrahl
Copy link
Contributor Author

After some additional checking it looks like there's a problem with Internet Explorer failing to render this RegEx expression causing a markdown document to fail loading. Apparently the look behind regex is not supported in IE, but works in newer browsers.

Not sure what the solution to that issue is. Perhaps conditional code with a different string for IE check.

Unfortunately IE is what I currently need this to work in as this is a desktop application with an embedded WebBrowser control. 😏

Check user agent and conditionally render italics with explict user agent check.
…therbrowsers except the backreference in the RegEx. This isn't perfect, but will help prevent inline `_` highlighting if the underlines are not at the end followed by whitespace. This should address a large percentage of cases where this was a problem originally.
@RickStrahl
Copy link
Contributor Author

RickStrahl commented Aug 15, 2020

So one of the Markdown tests is failing after this change. I've tried to figure out what that particular test checks for, but I can't see what the token / value combo accomplishes...

This change will change behavior in some cases, but legit italics should still work as before. Unfortunately I can't tell what the actual values are that are being tested in the failing test.

Maybe somebody more familiar with the testing of markdown formatting can take a look at the failing italics test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants