From 0be95ad2283d250c3fb71d34aa0e33c9645541bf Mon Sep 17 00:00:00 2001 From: Collin Beczak Date: Fri, 5 Jun 2026 14:01:05 -0300 Subject: [PATCH] Fix markdown shortcode regex dropping text around inner brackets The shortcode tokenizer regex allowed `[` inside bracketed content, so input like `[HIDDEN TEXT [way 2343242]]` was matched as one shortcode and OSMElementHandler then extracted only the OSM element, silently dropping the surrounding text. The `[[way 1]]` form lost one bracket the same way. Excluding `[` from the inner character class makes the regex match only the innermost brackets, leaving surrounding text untouched. --- src/services/Templating/Templating.jsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/services/Templating/Templating.jsx b/src/services/Templating/Templating.jsx index 3015824a3..e74ec409d 100644 --- a/src/services/Templating/Templating.jsx +++ b/src/services/Templating/Templating.jsx @@ -24,8 +24,10 @@ const shortCodeHandlers = [ // Short codes are surrounded by brackets, but -- to avoid confusion with // Markdown links -- cannot be immediately followed by an open parenthesees // (hence the lookahead at the end). Alternatively, triple curly braces can be -// used -const shortCodeRegex = /(\{\{\{[^}]+}}})|(\[[^\]]+\])(?=[^(]|$)/; +// used. The bracket form excludes `[` from its content so the regex matches +// the innermost brackets and leaves surrounding text (e.g. `[[way 1]]` or +// `[note [way 1]]`) intact rather than greedily swallowing it. +const shortCodeRegex = /(\{\{\{[^}]+}}})|(\[[^\][]+\])(?=[^(]|$)/; /** * Determines if the given string content contains one or more short-codes