Allow encode mailto and self target link in markdown

On translation files
This commit is contained in:
Andrey Antukh 2025-06-06 11:26:15 +02:00
parent e464d8cf9c
commit de2695682d
2 changed files with 20 additions and 10 deletions

View file

@ -237,18 +237,29 @@ async function renderTemplate(path, context = {}, partials = {}) {
return mustache.render(content, context, partials); return mustache.render(content, context, partials);
} }
const extension = { const markedOptions = {
useNewRenderer: true,
renderer: { renderer: {
link(token) { link(token) {
if (token.href === "mailto") {
return `<a href="mailto:${token.text}">${token.text}</a>`;
} else {
let target = "_blank";
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 href = token.href;
const text = token.text; const text = token.text;
return `<a href="${href}" target="_blank">${text}</a>`; return `<a href="${href}" target="${target}">${text}</a>`;
}, }
}, }
}; }
}
marked.use(extension); marked.use(markedOptions);
async function readTranslations() { async function readTranslations() {
const langs = [ const langs = [

View file

@ -120,7 +120,6 @@ function run-devenv-isolated-shell {
$DEVENV_IMGNAME:latest sudo -EH -u penpot bash $DEVENV_IMGNAME:latest sudo -EH -u penpot bash
} }
function build { function build {
echo ">> build start: $1" echo ">> build start: $1"
local version=$(print-current-version); local version=$(print-current-version);