diff options
Diffstat (limited to 'src/dumbymap.mjs')
-rw-r--r-- | src/dumbymap.mjs | 12 |
1 files changed, 5 insertions, 7 deletions
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) => { | |||
49 | .use(MarkdownItInjectLinenumbers) | 49 | .use(MarkdownItInjectLinenumbers) |
50 | 50 | ||
51 | // Create links with geo scheme | 51 | // Create links with geo scheme |
52 | const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/g | 52 | const coordinateRegex = /^(\D*)(-?\d+\.?\d*)\s*([,\x2F\uFF0C])\s*(-?\d+\.?\d*)/ |
53 | const coordinateValue = { | 53 | const coordinateValue = { |
54 | validate: coordinateRegex, | 54 | validate: coordinateRegex, |
55 | normalize: function (match) { | 55 | normalize: function (match) { |
56 | const matches = [...match.raw.matchAll(coordinateRegex)] | 56 | const [, , x, sep, y] = match.text.match(coordinateRegex) |
57 | if (!matches[0]) return match | ||
58 | const [, , x, sep, y] = matches[0] | ||
59 | match.url = `geo:${y},${x}?xy=${x},${y}` | 57 | match.url = `geo:${y},${x}?xy=${x},${y}` |
60 | match.text = `${x}${sep}${y}` | 58 | match.text = `${x}${sep} ${y}` |
61 | match.index = match.raw.indexOf(x) | 59 | match.index += match.text.indexOf(x) + 1 |
62 | return match | 60 | return match |
63 | } | 61 | } |
64 | } | 62 | } |
65 | const patterns = ['(', '📍', '\uFF08', '@', 'geo:', 'twd'] | 63 | const patterns = ['[', '(', '📍', '\uFF08', '@', 'geo:', 'twd'] |
66 | patterns.forEach(prefix => | 64 | patterns.forEach(prefix => |
67 | md.linkify.add(prefix, coordinateValue) | 65 | md.linkify.add(prefix, coordinateValue) |
68 | ) | 66 | ) |