From de2695682d9899b0e5e04e33fe6d1e7c4a74613a Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 6 Jun 2025 11:26:15 +0200 Subject: [PATCH] :sparkles: Allow encode mailto and self target link in markdown On translation files --- frontend/scripts/_helpers.js | 29 ++++++++++++++++++++--------- manage.sh | 1 - 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/frontend/scripts/_helpers.js b/frontend/scripts/_helpers.js index 5df2acf0da..7602b9c149 100644 --- a/frontend/scripts/_helpers.js +++ b/frontend/scripts/_helpers.js @@ -237,18 +237,29 @@ async function renderTemplate(path, context = {}, partials = {}) { return mustache.render(content, context, partials); } -const extension = { - useNewRenderer: true, +const markedOptions = { renderer: { link(token) { - const href = token.href; - const text = token.text; - return `${text}`; - }, - }, -}; + if (token.href === "mailto") { + return `${token.text}`; + } else { + let target = "_blank"; -marked.use(extension); + if (token.text.endsWith("|target:self")) { + const index = token.text.indexOf("|target:self"); + token.text = token.text.substring(0, index); + target = "_self"; + } + + const href = token.href; + const text = token.text; + return `${text}`; + } + } + } +} + +marked.use(markedOptions); async function readTranslations() { const langs = [ diff --git a/manage.sh b/manage.sh index 6d508922e2..4e8e8374d8 100755 --- a/manage.sh +++ b/manage.sh @@ -120,7 +120,6 @@ function run-devenv-isolated-shell { $DEVENV_IMGNAME:latest sudo -EH -u penpot bash } - function build { echo ">> build start: $1" local version=$(print-current-version);