From ce3cbedd2eb081552d961c8773c05d0dc4cc9324 Mon Sep 17 00:00:00 2001 From: Ole Eskild Steensen Date: Wed, 13 Apr 2022 09:04:17 +0200 Subject: [PATCH] Fix bug with callout block rendering --- .eleventy.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 8d2774298..e112bfb78 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -151,10 +151,15 @@ module.exports = function(eleventyConfig) { eleventyConfig.addTransform('callout-block', function(str) { - return str && str.replace(/
((.|\n)*)<\/blockquote>/g, function(match, content) { + return str && str.replace(/
((.|\n)*?)<\/blockquote>/g, function(match, content) { let titleDiv = ""; let calloutType = ""; - content = content.replace(/\[!(\w*)\](\s?.*)/g, function(metaInfoMatch, callout, title) { + const calloutMeta = /\[!(\w*)\](\s?.*)/g; + if(!content.match(calloutMeta)){ + return match; + } + + content = content.replace(calloutMeta, function(metaInfoMatch, callout, title) { calloutType = callout; titleDiv = title.replace("
", "") ? `
${title}
` :