From 2f53eb263359643f376841c3babd5be67ee0c708 Mon Sep 17 00:00:00 2001 From: Sergey Kolesnik Date: Mon, 10 Apr 2023 00:50:19 +0300 Subject: [PATCH] fix(views): render image link only when "!" specified --- src/utils/mldoc_ast.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/mldoc_ast.ts b/src/utils/mldoc_ast.ts index d16f488..ce8d2f9 100644 --- a/src/utils/mldoc_ast.ts +++ b/src/utils/mldoc_ast.ts @@ -259,7 +259,7 @@ class MldocASTtoHTMLCompiler { let label = '' if (data.label && data.label.length) { const node = data.label[0] - // handle case when label is plain text: to reduce `process`` call + // handle case when label is plain text: to reduce `process` call if (node && node.length && node[0] === 'Plain') label = node.at(1) ?? '' else @@ -273,7 +273,8 @@ class MldocASTtoHTMLCompiler { { case 'Search': { const term = url ?? '' const [ protocol, link ] = resolveAssetsLink(this.context, '', term) - if (protocol) + const inclusion = data.full_text.startsWith('!') + if (inclusion && protocol) return this.createImageLink(protocol, link, label, meta) return this.createPageRef(term, label) } case 'Page_ref': {