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

feat(hashtags) Do not alter #... found within code/pre blocks #483

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

steven-fox
Copy link
Collaborator

Was brought up that code blocks were experiencing problems with the new hashtag highlighting.

This PR adjusts the regex to exclude # symbols discovered within pre or code blocks (as well as a elements we had previously).

Before:
image

After:
image

Tests are good.
image

@nunomaduro nunomaduro merged commit b1596bd into main Aug 4, 2024
@nunomaduro nunomaduro deleted the fix/hashtags-and-code-blocks branch August 4, 2024 15:59
@@ -14,10 +14,10 @@
public function parse(string $content): string
{
return (string) preg_replace_callback(
'/(<a\s+[^>]*>.*?<\/a>)|(?<!&)#([a-z0-9_]+)/i',
'/(<(a|code|pre)\s+[^>]*>.*?<\/\2>)|(?<!&)#([a-z0-9_]+)/is',
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you just check for style attr?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don’t think we want that. It would mess up any # symbols found within the code of the code block, like the examples I posted. I think it’s best if we totally disable hashtag checking/highlighting from a, pre, and code elements.

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.

3 participants