From 66cff7249580989da37ee361ad92f1390a3d29db Mon Sep 17 00:00:00 2001
From: Ruben Bimberg <ruben.bimberg@mni.thm.de>
Date: Tue, 21 Sep 2021 22:30:26 +0200
Subject: [PATCH] Fix quotation marks within the topic cloud

---
 .../components/shared/tag-cloud/tag-cloud.component.ts    | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/app/components/shared/tag-cloud/tag-cloud.component.ts b/src/app/components/shared/tag-cloud/tag-cloud.component.ts
index 29ca074b9..40e8a1c18 100644
--- a/src/app/components/shared/tag-cloud/tag-cloud.component.ts
+++ b/src/app/components/shared/tag-cloud/tag-cloud.component.ts
@@ -51,6 +51,7 @@ class CustomPosition implements Position {
 class TagComment implements CloudData {
 
   constructor(public text: string,
+              public realText: string,
               public rotate: number,
               public weight: number,
               public tagData: TagCloudDataTagEntry,
@@ -66,6 +67,8 @@ class TagComment implements CloudData {
 const transformationScaleKiller = /scale\([^)]*\)/;
 const transformationRotationKiller = /rotate\(([^)]*)\)/;
 
+const quotationMarksRegex = /[“”‘’„‚«»‹›『』﹃﹄「」﹁﹂",《》〈〉'`]|((?<=\s)(lu|li’u)(?=\s))|(^lu(?=\s))|((?<=\s)li’u$)/gm;
+
 @Component({
   selector: 'app-tag-cloud',
   templateUrl: './tag-cloud.component.html',
@@ -305,7 +308,8 @@ export class TagCloudComponent implements OnInit, OnDestroy, AfterContentInit {
           if (rotation === null || this._currentSettings.randomAngles) {
             rotation = Math.floor(Math.random() * 30 - 15);
           }
-          newElements.push(new TagComment(tag, rotation, tagData.weight, tagData, newElements.length));
+          const filteredTag = tag.replace(quotationMarksRegex, '').trim();
+          newElements.push(new TagComment(filteredTag, tag, rotation, tagData.weight, tagData, newElements.length));
         }
       }
     }
@@ -423,7 +427,7 @@ export class TagCloudComponent implements OnInit, OnDestroy, AfterContentInit {
         const transformMatch = elem.style.transform.match(transformationRotationKiller);
         elem.dataset['tempRotation'] = transformMatch ? transformMatch[1] : '0deg';
         elem.style.transform = elem.style.transform.replace(transformationRotationKiller, '').trim();
-        this.popup.enter(elem, dataElement.text, dataElement.tagData,
+        this.popup.enter(elem, dataElement.realText, dataElement.tagData,
           (this._currentSettings.hoverTime + this._currentSettings.hoverDelay) * 1_000,
           this.room && this.room.blacklistIsActive);
       });
-- 
GitLab