Commit 520610a2 authored by pestov's avatar pestov
Browse files

Render note>bibl>ref as links inside of a note annotation

parent 3ffa0d9c
Pipeline #332009 passed with stages
in 22 minutes and 6 seconds
......@@ -380,19 +380,29 @@ class EditedTextTransformer extends CommonTransformer
if ($target) {
$htmlEl = $doc->a($target);
// There can be self closing <ref/> tags, so we just add the target as content for the <a> tag.
if (!$teiEl->hasChildNodes()) {
// There can be self-closing <ref/> tags, so we just add the target as content for the <a> tag.
if (!$teiEl->hasChildNodes() && !$teiEl->textContent) {
$htmlEl->appendChild($doc->text($target));
}
if ('bibl' === $teiEl->parentNode->nodeName) {
$htmlEl = $doc->span();
$targetArr = explode('#', $target);
$url = './../literatur/'.$targetArr[1];
$text = str_replace('_', ' ', $targetArr[1]);
// Create annotation
// If we have note > bibl > ref, then we are here in the middle of note HTML doc
// instead of the actual edited text HTMl doc.
// So we just want to display the link in there.
if ('note' === $teiEl->parentNode->parentNode->nodeName) {
return $doc->a($url);
}
// Otherwise it appears to be a regular bibl inside of the edited text.
// So we create a respective annotation for it and put this link as part of it's text.
$htmlEl = $doc->span();
$uuid = $this->createUuid();
$text = str_replace('_', ' ', $targetArr[1]);
$this->works[$uuid] = $text.' (<a href="'.$url.'" target="_blank">Literaturverzeichnis</a>)';
$this->literature[$uuid] = $targetArr[1];
$htmlEl->setAttribute('id', $uuid);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment