A DataTables plugin for mark.js to highlight search terms in tables
$ npm install datatables.mark.js --save-dev
Or with Bower using:
$ bower install datatables.mark.js --save-dev
Alternatively the plugin is also available on the following CDN's:
- DataTables CDN listed under plugins -> features. For example the links for DataTables v1.10.13 can be found here
Because the DataTables CDN only updates plugins at own releases and you can't specify an explicit plugin version, it's recommended to use jsDelivr.
This plugin depends on:
- DataTables v1.10.6+
- jQuery v1.7+ (necessary by DataTables)
- mark.js v6.2+ (the jQuery version)
When using a module loader like CommonJS (e.g. Webpack) or AMD (e.g. RequireJS) they will be loaded automatically.
Finally, you'll have to embed one of these files:
- datatables.mark.es6.js: Uncompressed ES6
- datatables.mark.es6.min.js: Compressed ES6 (recommended when using ES6)
- datatables.mark.js: Uncompressed ES5
- datatables.mark.min.js: Compressed ES5 (recommended when using ES5)
into your application, by either referencing the file manually using e.g.:
or loading it with AMD or CommonJS.
When using RequireJS you should configure the names of dependent modules as following:
- jQuery must be named "jquery"
- DataTables must be named "datatables.net" (defined by DataTables itself)
- mark.js must be named "markjs"
This is important as datatables.mark.js will load these modules as dependencies. You might have a look at this example.
Activation in the DataTables options:
Activation by default for all DataTables instances:
Activation with custom mark.js options:
Please head over to the mark.js website for an overview of possible options.
Now that you've activated the plugin you just need to define your custom styles
for the highlighted elements. If you haven't defined a custom
className in the mark.js options the default element will be
having a class assigned. If you don't want to have custom styles, you can embed
one of the default CSS files:
See the contribution guidelines.
Changes are documented in release descriptions.