28 const PLACEHOLDER =
" # ";
31 private $elementStack;
33 private $highlightRenderer;
37 private $insertBacklink;
39 public function __construct(
HighlightRenderer $highlightRenderer, $insertBacklink =
false)
41 $this->highlightRenderer = $highlightRenderer;
42 $this->insertBacklink = $insertBacklink;
43 $this->elementStack = array();
51 array_push($this->elementStack, $splitPosition);
59 return array_pop($this->elementStack);
67 return $this->elementStack;
75 foreach ($entries as $entry) {
76 switch ($entry->getAction()) {
77 case SplitPosition::START:
81 case SplitPosition::END:
94 foreach ($entries as $entry) {
95 switch ($entry->getAction()) {
96 case SplitPosition::START:
100 case SplitPosition::ATOM:
103 self::PLACEHOLDER . $this->highlightRenderer->createSpanEnd($entry));
106 case SplitPosition::END:
109 $this->highlightRenderer->createSpanEnd($entry));
120 foreach ($this->elementStack as $splitPosition) {
122 $this->highlightRenderer->createSpanEnd($splitPosition));
131 foreach ($this->elementStack as $entry) {
132 $result->
appendMetaText($this->highlightRenderer->createSpanStart($entry));
143 ?
"<a id=\"highlight\"" . ($this->insertBacklink ?
" href=\"#top\"> ↑ " :
">") .
"</a>" 146 return $anchorText . $this->highlightRenderer->createSpanStart($entry);
155 $shouldShowAnchor = !$this->anchorDrawn && $entry->
getHighlight()->getType() != Highlight::KEYWORD;
156 if ($shouldShowAnchor) {
157 $this->anchorDrawn =
true;
159 return $shouldShowAnchor;
insertElements($entries, PagedResult $result)
closeOpenElements(PagedResult $result)
processSplitEntries($entries)
checkForAnchor(SplitPosition $entry)
openExistingElements(PagedResult $result)
startSpan(SplitPosition $entry)
push(SplitPosition $splitPosition)