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

skip rewrite-icons for certain conditions #348

Closed
maxakuru opened this issue Jul 13, 2023 · 6 comments · Fixed by #349
Closed

skip rewrite-icons for certain conditions #348

maxakuru opened this issue Jul 13, 2023 · 6 comments · Fixed by #349
Labels
question Further information is requested released on @3.x released

Comments

@maxakuru
Copy link
Member

maxakuru commented Jul 13, 2023

The current behavior for icons is to rewrite any text that matches /:(#?[a-z_-]+[a-z\d]*):/gi with a span

Problem: this replaces strings that intentionally use colons inside them, like URNs

There are a couple cases I think this could be avoided without being too much of an impact:

  1. inside code elements
  • I would argue it's unlikely authors intend to insert icons inside code blocks, at least when being used for code
  • this would match github/slack functionality, eg. 👍 :+1:
  1. inside urns/hrefs
  • URNs may exist in content
  • some links contain URNs or path segments that resemble URNs, eg. sharepoint
  • unlikely icons are intentionally inserted into those patterns
    • (?<!(?:https?|urn)[^\s]*):(#?[a-z_-]+[a-z\d]*):
    • can't begin with urn:, http: or https:
@maxakuru maxakuru added the question Further information is requested label Jul 13, 2023
@maxakuru
Copy link
Member Author

this would technically be a breaking change, but not sure how often each case might be relied on right now

wdyt @tripodsan @trieloff @dominique-pfister ?

@tripodsan
Copy link
Contributor

I think this is ok. @davidnuescheler should decide :-)

@bstopp
Copy link

bstopp commented Jul 14, 2023

What about not processing unless they are terminated by spaces? or that are at word boundaries? (Trying to determine how to still process when it's the only content, but not if it's in contiguous content.

/\b:(#?[a-z_-]+[a-z\d]*):\b/gi

@maxakuru
Copy link
Member Author

@bstopp I think that is contrary to what people are used to in places like slack or:rocket:github, which is nice to stick close to for icons imo

for URNs I think case 2 could just be adjusted to include urn: as an ignored scheme along with https?:

github-actions bot pushed a commit that referenced this issue Jul 18, 2023
## [4.0.1](v4.0.0...v4.0.1) (2023-07-18)

### Bug Fixes

* ignore urns, hrefs, code blocks for rewrite-icons ([d61e23a](d61e23a)), closes [#348](#348)
@github-actions
Copy link

🎉 This issue has been resolved in version 4.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

tripodsan added a commit that referenced this issue Jul 18, 2023
fixes #348

Co-authored-by: Max Edell <mgedell@gmail.com>
github-actions bot pushed a commit that referenced this issue Jul 18, 2023
## [3.11.22](v3.11.21...v3.11.22) (2023-07-18)

### Bug Fixes

* ignore urns, hrefs, code blocks for rewrite-icons ([#355](#355)) ([8d1bd78](8d1bd78)), closes [#348](#348)
@github-actions
Copy link

🎉 This issue has been resolved in version 3.11.22 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested released on @3.x released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants