From 39572f4767f270a4a5a40d8973ae9824ac3a43d1 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Sat, 2 Sep 2023 01:57:03 +0200 Subject: [PATCH] Fix: remove all html-attributes from shortDescriptions in the theme overview --- scripts/fixQuestionHint.ts | 8 +++---- scripts/generateLayerOverview.ts | 41 +++++++++++++++++--------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/scripts/fixQuestionHint.ts b/scripts/fixQuestionHint.ts index e7b0a1b1e..1406d2b32 100644 --- a/scripts/fixQuestionHint.ts +++ b/scripts/fixQuestionHint.ts @@ -1,10 +1,10 @@ import * as fs from "fs" -import { DesugaringStep } from "../Models/ThemeConfig/Conversion/Conversion" -import { LayerConfigJson } from "../Models/ThemeConfig/Json/LayerConfigJson" -import { QuestionableTagRenderingConfigJson } from "../Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson" +import { DesugaringStep } from "../src/Models/ThemeConfig/Conversion/Conversion" +import { LayerConfigJson } from "../src/Models/ThemeConfig/Json/LayerConfigJson" +import { QuestionableTagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/QuestionableTagRenderingConfigJson" import * as fakedom from "fake-dom" import Script from "./Script" -import { FixedUiElement } from "../UI/Base/FixedUiElement" +import { FixedUiElement } from "../src/UI/Base/FixedUiElement" class ExtractQuestionHint extends DesugaringStep { constructor() { diff --git a/scripts/generateLayerOverview.ts b/scripts/generateLayerOverview.ts index 8cf68d9ff..1314f3578 100644 --- a/scripts/generateLayerOverview.ts +++ b/scripts/generateLayerOverview.ts @@ -1,26 +1,26 @@ -import ScriptUtils from "./ScriptUtils" -import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs" -import licenses from "../src/assets/generated/license_info.json" -import { LayoutConfigJson } from "../src/Models/ThemeConfig/Json/LayoutConfigJson" -import { LayerConfigJson } from "../src/Models/ThemeConfig/Json/LayerConfigJson" -import Constants from "../src/Models/Constants" +import ScriptUtils from "./ScriptUtils"; +import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs"; +import licenses from "../src/assets/generated/license_info.json"; +import { LayoutConfigJson } from "../src/Models/ThemeConfig/Json/LayoutConfigJson"; +import { LayerConfigJson } from "../src/Models/ThemeConfig/Json/LayerConfigJson"; +import Constants from "../src/Models/Constants"; import { DetectDuplicateFilters, DoesImageExist, PrevalidateTheme, ValidateLayer, - ValidateThemeAndLayers, -} from "../src/Models/ThemeConfig/Conversion/Validation" -import { Translation } from "../src/UI/i18n/Translation" -import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson" -import PointRenderingConfigJson from "../src/Models/ThemeConfig/Json/PointRenderingConfigJson" -import { PrepareLayer } from "../src/Models/ThemeConfig/Conversion/PrepareLayer" -import { PrepareTheme } from "../src/Models/ThemeConfig/Conversion/PrepareTheme" -import { DesugaringContext } from "../src/Models/ThemeConfig/Conversion/Conversion" -import { Utils } from "../src/Utils" -import Script from "./Script" -import { AllSharedLayers } from "../src/Customizations/AllSharedLayers" - + ValidateThemeAndLayers +} from "../src/Models/ThemeConfig/Conversion/Validation"; +import { Translation } from "../src/UI/i18n/Translation"; +import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson"; +import PointRenderingConfigJson from "../src/Models/ThemeConfig/Json/PointRenderingConfigJson"; +import { PrepareLayer } from "../src/Models/ThemeConfig/Conversion/PrepareLayer"; +import { PrepareTheme } from "../src/Models/ThemeConfig/Conversion/PrepareTheme"; +import { DesugaringContext } from "../src/Models/ThemeConfig/Conversion/Conversion"; +import { Utils } from "../src/Utils"; +import Script from "./Script"; +import { AllSharedLayers } from "../src/Customizations/AllSharedLayers"; +import {parse as parse_html} from "node-html-parser" // This scripts scans 'src/assets/layers/*.json' for layer definition files and 'src/assets/themes/*.json' for theme definition files. // It spits out an overview of those to be used to load them @@ -516,7 +516,10 @@ class LayerOverviewUtils extends Script { hideFromOverview: t.hideFromOverview ?? false, shortDescription: t.shortDescription ?? - new Translation(t.description).FirstSentence().translations, + new Translation(t.description) + .FirstSentence() + .OnEveryLanguage(s => parse_html(s).innerText) + .translations, mustHaveLanguage: t.mustHaveLanguage?.length > 0, } })