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/dumbyUtils.mjs | 4 ++-- src/dumbymap.mjs | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs index 5de5b05..d0a3501 100644 --- a/src/dumbyUtils.mjs +++ b/src/dumbyUtils.mjs @@ -101,10 +101,10 @@ const getMarkersFromMaps = link => { .map(map => { const renderer = map.renderer - return map.querySelector(`.marker[title="${link.title}"]`) ?? + return map.querySelector(`.marker[title="${link.xy}"]`) ?? renderer.addMarker({ xy: link.xy, - title: link.title + title: link.xy }) }) } 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