Skip to content

Commit

Permalink
Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Riedel authored and Marcel Riedel committed Apr 4, 2024
2 parents de3882a + 48d60aa commit 975099b
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions frontend/app/search/search.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/<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";
}
} 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 975099b

Please sign in to comment.