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

Use custom blackfriday renderer to only add mention/hashtag links in normal text #787

Merged
merged 2 commits into from
Aug 31, 2022

Conversation

blackle
Copy link
Contributor

@blackle blackle commented Aug 31, 2022

fixes #783. blackfriday lets you specify your own renderer, which gives us more control over where we insert the hashtag/mention links. see: https://github.com/russross/blackfriday/blob/v2/html.go#L508

basically, blackfriday.Text signals raw text output, and blackfriday.Code signals code block output, so we can avoid making the conversion there.

caveat: posting something like:

_#hashtag_

doesn't turn #hashtag into a hashtag, but

_#hashtag #hashtag #hashtag_

converts all three, so I think the code that generates the tag list needs some work in the markdown case.

@blackle blackle force-pushed the fix-markdown-code branch 2 times, most recently from 2f775c1 to eacd6a9 Compare August 31, 2022 03:03
@tsmethurst
Copy link
Contributor

Nice fix! Can you add a couple test cases for this in the text package?

I think the code that generates the tag list needs some work in the markdown case

mm, sounds like it 🤔 we should open another issue to figure out these cases, will you do it or should I?

@blackle
Copy link
Contributor Author

blackle commented Aug 31, 2022

added more tests, also opened #789 for the other issue

@blackle blackle force-pushed the fix-markdown-code branch from f5dfb0f to 1c94031 Compare August 31, 2022 15:35
@tsmethurst tsmethurst merged commit f01492a into superseriousbusiness:main Aug 31, 2022
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.

[bug] Hashtags inside markdown pre-blocks are rendered as HTML links
2 participants