From 15ed827db753dc4a137c3ac58d6b6207da874b0a Mon Sep 17 00:00:00 2001 From: Paul Pestov Date: Tue, 26 Oct 2021 12:30:36 +0200 Subject: [PATCH] Add hand attribute handling to del tag transform --- src/Service/TranscriptionService.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Service/TranscriptionService.php b/src/Service/TranscriptionService.php index bca3fc6..54d8f30 100644 --- a/src/Service/TranscriptionService.php +++ b/src/Service/TranscriptionService.php @@ -61,12 +61,32 @@ class TranscriptionService extends CommonTransformService { $htmlEl = $doc->span(); $htmlEl->appendChild($doc->text(' [')); + $this->transformAllChildren($teiEl, $htmlEl, $doc); $italic = $doc->span(); $italic->setAttribute('class', 'italic'); - $italic->appendChild($doc->text(' Str.')); - $htmlEl->appendChild($italic); + if (empty($teiEl->attributes)) { + $italic->appendChild($doc->text(' Str.')); + } else { + foreach ($teiEl->attributes as $attribute) { + if ('hand' === $attribute->nodeName) { + if (strpos($attribute->nodeValue, 'scrb') !== false) { + $valueArr = explode('scrb', $attribute->nodeValue); + if (isset($valueArr[1])) { + $valueArr = explode('_', ltrim($valueArr[1], '_')); + if (count($valueArr) === 2) { + $italic->appendChild($doc->text(' str Schrhd.' . $valueArr[0] . ' ' . $valueArr[1])); + } + } + } else { + $italic->appendChild($doc->text(' str. ' . str_replace('_', ' ', trim($attribute->nodeValue, '#')))); + } + } + } + } + + $htmlEl->appendChild($italic); $htmlEl->appendChild($doc->text('] ')); return $htmlEl; } -- GitLab