Skip to content

Commit

Permalink
Add support for slashes in tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Ole Eskild Steensen committed Jan 21, 2023
1 parent 3176a78 commit 255e1d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -194,7 +196,7 @@ module.exports = function (eleventyConfig) {
return (
str &&
str.replace(
/(^|\s|\>)(#[^\s!@#$%^&*()=+\.\/,\[{\]};:'"?><]+)(?!([^<]*>))/g,
tagRegex,
function (match, precede, tag) {
return `${precede}<a class="tag" onclick="toggleTagSearch(this)">${tag}</a>`;
}
Expand All @@ -207,7 +209,7 @@ module.exports = function (eleventyConfig) {
let match =
str &&
str.match(
/(^|\s|\>)(#[^\s!@#$%^&*()=+\.\/,\[{\]};:'"?><]+)(?!([^<]*>))/g
tagRegex,
);
if (match) {
tags = match
Expand Down

0 comments on commit 255e1d5

Please sign in to comment.