From 9d88ee357060abe90c85c4ade5fca61592c0f032 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sat, 5 Oct 2024 16:39:52 +0800 Subject: fix: patch 9a0fdb9 * use attribute "xy" as title of marker * fix config for linkify --- src/dumbymap.mjs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/dumbymap.mjs') diff --git a/src/dumbymap.mjs b/src/dumbymap.mjs index 512409b..7489b1a 100644 --- a/src/dumbymap.mjs +++ b/src/dumbymap.mjs @@ -49,20 +49,18 @@ export const markdown2HTML = (container, mdContent) => { .use(MarkdownItInjectLinenumbers) // Create links with geo scheme - const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/g + const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/ const coordinateValue = { validate: coordinateRegex, normalize: function (match) { - const matches = [...match.raw.matchAll(coordinateRegex)] - if (!matches[0]) return match - const [, , x, sep, y] = matches[0] + const [, , x, sep, y] = match.text.match(coordinateRegex) match.url = `geo:${y},${x}?xy=${x},${y}` - match.text = `${x}${sep}${y}` - match.index = match.raw.indexOf(x) + match.text = `${x}${sep} ${y}` + match.index += match.text.indexOf(x) + 1 return match } } - const patterns = ['(', '📍', '\uFF08', '@', 'geo:', 'twd'] + const patterns = ['[', '(', '📍', '\uFF08', '@', 'geo:', 'twd'] patterns.forEach(prefix => md.linkify.add(prefix, coordinateValue) ) -- cgit v1.2.3-70-g09d2