MrkrJS is a super simple package I created for a project to highlight blocks of text with arbitrary CSS
. It's 100% vanilla JavaScript and uses various browser APIs like getRange
to apply classes to text nodes.
The project that called for this utility required that certain "correct" sentences or pieces of text needed to be highlighted (within a certain tolerance), so we used this package to both apply highlighted styles to the selected text as well as determine whether it was correctly selected or not. You can also programmatically highlight blocks of text nodes as you see fit, without using the mouse cursor.
This was also an instructive exercise in learning how to configure a package for public consumption on npm
. I ended up using Rollup to package the library into both bundled and unbundled packages for uninhibited enjoyment.
Vanilla JavaScript
Rollup - for bundling
T. 2023