Add support for extensions
See original GitHub issueI think it would be nice to add a method to mark.js to support plugins/extensions.
I had a crazy idea - I told you I tend to go overboard on ideas - about being able to highlight links (<a>
) based on their url. So if I search for github
, it would highlight all links with “github” in their href
attribute. Of course this could be extended to highlight any element with matching data-attributes as well. Crazy idea huh?
The current synonyms
setting would not work in this case. I tried the filter
callback and I found node
is only returning text nodes. So there would need to be a change to the API, I think.
I definitely don’t think this should be part of the core plugin, which is why I thought the ability to add plugin/extensions would be cool/interesting/crazy/.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I was thinking that the
done
callback provided the query value, so you could then add that code snippet to mark the links, but now I see it doesn’t. And if any previousmark
elements added would be removed. I guess thatdata-markjs
attribute could be added if you wanted the.unmark()
function to clear up the highlights.U.S. central time zone… I live in the land of Oz. Dorothy is my neighbor and I spray Toto with a water hose all the time because he barks too much.
Anyway, now that I think about it, there isn’t really a need for plugin/extension support as pretty much everything can be done with callbacks or outside of mark.js. Thanks for listening and tolerating my ramblings!
I think so too. There was a user that used mark.js to highlight mentions and hashtags using a RegExp, e.g.
@mention
or#hashtag
. He used thea
element and added ahref
attribute on eacheach
callback call. But this is the only use case I see with links here. Just finding elements and not just text parts can be done by native DOM methods.Anyway, I appreciate you’re getting involved in mark.js and finding further use cases is helpful! So gladly again.