From a05ce3d8ec30db2348c11e7c8d7289686266f1da Mon Sep 17 00:00:00 2001 From: Ral Date: Wed, 26 Feb 2025 20:32:45 +0100 Subject: [PATCH] Autofix some markdown --- assets/js/custom/dom/upcoming-talk.js | 8 ++++++-- assets/js/custom/services/service.js | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/assets/js/custom/dom/upcoming-talk.js b/assets/js/custom/dom/upcoming-talk.js index 6208379..428a3b9 100644 --- a/assets/js/custom/dom/upcoming-talk.js +++ b/assets/js/custom/dom/upcoming-talk.js @@ -42,11 +42,13 @@ const event_description = (event) => { const dtext = sol.defined(description) ? description : ""; const text = atext.length >= dtext.length ? atext : dtext; + const text_fixed = serv.fix_markdown(text); + const text_fixed_urls = serv.fix_markdown_urls(text_fixed); return html`
Beschreibung:
-
${text}
+
${text_fixed_urls}
`; }; @@ -56,13 +58,15 @@ const event_content = (event) => const speaker_info = (speaker, count) => { const name = serv.fix_dash(sol.personName(speaker)); const bio = sol.personBiography(speaker); + const btext = sol.defined(bio) ? bio : ""; + const bio_fixed = serv.fix_markdown_urls(btext); let inner; if (sol.defined(bio) && bio.length >= minBioLength) { inner = html`
${name}
-
${bio}
+
${bio_fixed}
`; } else { inner = html``; diff --git a/assets/js/custom/services/service.js b/assets/js/custom/services/service.js index d031600..a804890 100644 --- a/assets/js/custom/services/service.js +++ b/assets/js/custom/services/service.js @@ -36,10 +36,25 @@ const fix_dash = (string) => string.replace(ndash_fix_regexp, ndash_fix_replacement); +const markdown_fix_regexp = '**'; +const markdown_fix_replacement = ''; + +const fix_markdown = (string) => + string.replaceAll(markdown_fix_regexp, markdown_fix_replacement); + + +const url_fix_regexp = RegExp('\\[([^\\]]+)\\]\\([^)]+\\)', "g"); + +const fix_markdown_urls = (string) => + string.replace(url_fix_regexp, '$1'); + + export { process_data, track_index, sort_tracks, person_names_concat, - fix_dash + fix_dash, + fix_markdown, + fix_markdown_urls }