PHP code example of mindkomm / commonmark-searchhighlight-extension
1. Go to this page and download the library: Download mindkomm/commonmark-searchhighlight-extension library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mindkomm / commonmark-searchhighlight-extension example snippets
use League\CommonMark\Environment;
use League\CommonMark\CommonMarkConverter;
use Mind\CommonMark\SearchHighlightExtension\SearchHighlightExtension;
$searchstring = 'Your search string';
$config = [];
$environment = Environment::createCommonMarkEnvironment();
if (!empty($searchstring)) {
// Pass the search string to the constructor.
$environment->addExtension(new SearchHighlightExtension($searchstring));
}
$converter = new CommonMarkConverter($config, $environment);
echo $converter->convertToHtml('A text that contains your search string.');