From 255e1d531d852d16ff39f37c7871ebd36cd32df0 Mon Sep 17 00:00:00 2001 From: Ole Eskild Steensen Date: Sat, 21 Jan 2023 12:03:39 +0100 Subject: [PATCH] Add support for slashes in tags --- .eleventy.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index ca618f420..d53e6980c 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -8,6 +8,8 @@ const { parse } = require("node-html-parser"); const { headerToId, namedHeadingsFilter } = require("./src/helpers/utils"); +const tagRegex = /(^|\s|\>)(#[^\s!@#$%^&*()=+\.,\[{\]};:'"?><]+)(?!([^<]*>))/g; + module.exports = function (eleventyConfig) { let markdownLib = markdownIt({ breaks: true, @@ -194,7 +196,7 @@ module.exports = function (eleventyConfig) { return ( str && str.replace( - /(^|\s|\>)(#[^\s!@#$%^&*()=+\.\/,\[{\]};:'"?><]+)(?!([^<]*>))/g, + tagRegex, function (match, precede, tag) { return `${precede}${tag}`; } @@ -207,7 +209,7 @@ module.exports = function (eleventyConfig) { let match = str && str.match( - /(^|\s|\>)(#[^\s!@#$%^&*()=+\.\/,\[{\]};:'"?><]+)(?!([^<]*>))/g + tagRegex, ); if (match) { tags = match