From dbbf9fcf1d7bdcf3b2e2a3c94dc567c313115e90 Mon Sep 17 00:00:00 2001 From: Marcel Riedel Date: Fri, 22 Mar 2024 17:06:00 +0100 Subject: [PATCH] exclude "raw-"-labelKeys for catalogTextGeneration see: https://github.com/dainst/arachne4/commit/2399108289c7dca2c6c88f836948397308ebaec3 and: http://jira:8080/browse/RED-726 --- frontend/app/search/search.controller.js | 44 ++++++++++++++---------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/frontend/app/search/search.controller.js b/frontend/app/search/search.controller.js index 5280dcb94..c9541b33f 100644 --- a/frontend/app/search/search.controller.js +++ b/frontend/app/search/search.controller.js @@ -85,31 +85,39 @@ export default function ($rootScope, $scope, searchService, categoryService, $fi if (!section.content || section.content.length === 0) return ""; - var sectionText = ""; + let sectionText = ""; if (section.label && section.label.length > 0) { - sectionText += firstLevel ? "#" : "###"; - sectionText += " " + section.label + "\n"; + // skip technical labels ("raw" and "formatted") + if(section.label !== "raw" && section.label !== "formatted") { + sectionText += firstLevel ? "#" : "###"; + sectionText += " " + section.label + "\n"; + } } - for (var i in section.content) { - if (section.content[i].value) { - var value = ""; - if (Array.isArray(section.content[i].value)) { - for (var j in section.content[i].value) { - value += section.content[i].value[j] + " \n"; + // process nested sections + if(section.content.label !== "raw") { + for (let i in section.content) { + // use "formatted"-parts only + if(section.content[i].label !== "raw") { + if(section.content[i].value) { + let value = ""; + if (Array.isArray(section.content[i].value)) { + for (let j in section.content[i].value) { + value += section.content[i].value[j] + " \n"; + } + } else { + value = section.content[i].value; + } + value = value.replace(/
/g, " \n").replace(//g, " \n").replace(/
/g, " \n") + .replace(/-/g, "\\-").replace(/\*/g, "\\*").replace(/#/g, "\\#") + .replace(/(.*?)<\/a>/g, "[$3]($1)"); + sectionText += value + " \n"; + } else { + sectionText += $scope.createSectionText(section.content[i], false) + " \n"; } - } else { - value = section.content[i].value; } - value = value.replace(/
/g, " \n").replace(//g, " \n").replace(/
/g, " \n") - .replace(/-/g, "\\-").replace(/\*/g, "\\*").replace(/#/g, "\\#") - .replace(/
(.*?)<\/a>/g, "[$3]($1)"); - sectionText += value + " \n"; - } else { - sectionText += $scope.createSectionText(section.content[i], false) + " \n"; } } - return sectionText; };