Add support for extensionsSee original GitHub issue
I 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?
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/.
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
why you’re talking about done and .unmark()
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 previous
mark elements added would be removed. I guess that
data-markjs attribute could be added if you wanted the
.unmark() function to clear up the highlights.
May I ask for your timezone?
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!
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.
I think so too. There was a user that used mark.js to highlight mentions and hashtags using a RegExp, e.g.
#hashtag. He used the
a element and added a
href attribute on each
each 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.
Thanks for listening and tolerating my ramblings!
Anyway, I appreciate you’re getting involved in mark.js and finding further use cases is helpful! So gladly again.