anchorFormatter = $anchorFormatter; $this->markSymbolRenderer = $markSymbolRenderer; $this->messageLocalizer = $messageLocalizer; } /** * Generate a link ( element from a key * and return XHTML ready for output * * @suppress SecurityCheck-DoubleEscaped * @param Parser $parser * @param ReferenceStackItem $ref * * @return string HTML */ public function linkRef( Parser $parser, ReferenceStackItem $ref ): string { $label = $this->markSymbolRenderer->makeLabel( $ref->group, $ref->number, $ref->extendsIndex ); $key = $ref->name ?? $ref->key; // TODO: Use count without decrementing. $count = $ref->name ? $ref->key . '-' . ( $ref->count - 1 ) : null; $subkey = $ref->name ? '-' . $ref->key : null; return $parser->recursiveTagParse( $this->messageLocalizer->msg( 'cite_reference_link', $this->anchorFormatter->backLinkTarget( $key, $count ), $this->anchorFormatter->jumpLink( $key . $subkey ), Sanitizer::safeEncodeAttribute( $label ) )->plain() ); } }