Skip to content

Commit

Permalink
Revert "exclude "raw-"-labelKeys for catalogTextGeneration"
Browse files Browse the repository at this point in the history
This reverts commit dbbf9fc.
  • Loading branch information
dersmon committed Mar 26, 2024
1 parent dbbf9fc commit 9a171c5
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions frontend/app/search/search.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,39 +85,31 @@ export default function ($rootScope, $scope, searchService, categoryService, $fi

if (!section.content || section.content.length === 0) return "";

let sectionText = "";
var sectionText = "";
if (section.label && section.label.length > 0) {
// skip technical labels ("raw" and "formatted")
if(section.label !== "raw" && section.label !== "formatted") {
sectionText += firstLevel ? "#" : "###";
sectionText += " " + section.label + "\n";
}
sectionText += firstLevel ? "#" : "###";
sectionText += " " + section.label + "\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(/<hr>/g, " \n").replace(/<hr\/>/g, " \n").replace(/<hr \/>/g, " \n")
.replace(/-/g, "\\-").replace(/\*/g, "\\*").replace(/#/g, "\\#")
.replace(/<a href="(.*?)"( target="_blank")?>(.*?)<\/a>/g, "[$3]($1)");
sectionText += value + " \n";
} else {
sectionText += $scope.createSectionText(section.content[i], false) + " \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";
}
} else {
value = section.content[i].value;
}
value = value.replace(/<hr>/g, " \n").replace(/<hr\/>/g, " \n").replace(/<hr \/>/g, " \n")
.replace(/-/g, "\\-").replace(/\*/g, "\\*").replace(/#/g, "\\#")
.replace(/<a href="(.*?)"( target="_blank")?>(.*?)<\/a>/g, "[$3]($1)");
sectionText += value + " \n";
} else {
sectionText += $scope.createSectionText(section.content[i], false) + " \n";
}
}

return sectionText;
};

Expand Down

0 comments on commit 9a171c5

Please sign in to comment.