3 declare(strict_types
=1);
5 namespace Shaarli\Formatter\Parsedown
;
7 use Shaarli\Formatter\BookmarkDefaultFormatter
as Formatter
;
9 trait ShaarliParsedownTrait
11 protected function inlineLink($excerpt)
13 return $this->shaarliFormatLink(parent
::inlineLink($excerpt), true);
16 protected function inlineUrl($excerpt)
18 return $this->shaarliFormatLink(parent
::inlineUrl($excerpt), false);
21 protected function shaarliFormatLink(?array $link, bool $fullWrap): ?array
25 && strpos($link['element']['attributes']['href'], Formatter
::SEARCH_HIGHLIGHT_OPEN
) !== false
26 && strpos($link['element']['attributes']['href'], Formatter
::SEARCH_HIGHLIGHT_CLOSE
) !== false
28 $link['element']['attributes']['href'] = $this->shaarliRemoveSearchTokens(
29 $link['element']['attributes']['href']
33 $link['element']['text'] = Formatter
::SEARCH_HIGHLIGHT_OPEN
.
34 $link['element']['text'] .
35 Formatter
::SEARCH_HIGHLIGHT_CLOSE
43 protected function shaarliRemoveSearchTokens(string $entry): string
45 $entry = str_replace(Formatter
::SEARCH_HIGHLIGHT_OPEN
, '', $entry);
46 $entry = str_replace(Formatter
::SEARCH_HIGHLIGHT_CLOSE
, '', $entry);