Download the PHP package yarri/keywords-highlighter without Composer
On this page you can find all versions of the php package yarri/keywords-highlighter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download yarri/keywords-highlighter
More information about yarri/keywords-highlighter
Files in yarri/keywords-highlighter
Download yarri/keywords-highlighter
More information about yarri/keywords-highlighter
Files in yarri/keywords-highlighter
Vendor yarri
Package keywords-highlighter
Short Description Highlights keywords (typically a search query) in a HTML string
License MIT
Homepage https://github.com/yarri/KeywordsHighlighter
Package keywords-highlighter
Short Description Highlights keywords (typically a search query) in a HTML string
License MIT
Homepage https://github.com/yarri/KeywordsHighlighter
Please rate this library. Is it a good library?
Informations about the package keywords-highlighter
Keywords Highlighter
Highlights keywords (typically a search query) in a HTML string.
Basic usage
$html_text = '
<h1>The truth about pizza and beer</h1>
<p>
Beer and pizza.
It might be one of the most obvious food pairings on the planet...
</p>
';
$highlighter = new \Yarri\KeywordsHighlighter();
echo $highlighter->highlight($html_text,"pizza beer");
// <h1>The truth about <mark>pizza</mark> and <mark>beer</mark></h1>
//
// <p>
// <mark>Beer</mark> and <mark>pizza</mark>.
// It might be one of the most obvious food pairings on the planet...
// </p>
The default tag for highlighting can be overwritten in options of the constructor.
$highlighter = new \Yarri\KeywordsHighlighter([
"opening_tag" => '<span class="highlight">',
"closing_tag" => '</span>',
]);
echo $highlighter->highlight($html_text,"pizza beer");
// <h1>The truth about <span class="highlight">pizza</span> and <span class="highlight">beer</span></h1>
//
// <p>
// <span class="highlight">Beer</span> and <span class="highlight">pizza</span>.
// It might be one of the most obvious food pairings on the planet...
// </p>
KeywordsHighlighter doesn't highlight something inside a html tag.
$html_text = '
<h1>The truth about the H1 element</h1>
';
$highlighter = new \Yarri\KeywordsHighlighter();
echo $highlighter->highlight($html_text,"h1");
// <h1>The truth about the <mark>H1</mark> element</h1>
Installation
composer require yarri/keywords-highlighter
Testing
composer update --dev
cd test
../vendor/bin/run_unit_testsAll versions of keywords-highlighter with dependencies
PHP Build Version
Package Version
Requires
php Version
>=5.4.0
ext-mbstring Version *
ext-mbstring Version *
The package yarri/keywords-highlighter contains the following files
Loading the files please wait ...