From eddc4b584595200c3d1b6b8ba33df9f1b2b231c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Menu?= Date: Sun, 19 Dec 2021 15:52:15 +0100 Subject: [PATCH] Fix embedded image links shown as not found (#127) --- CHANGELOG.md | 7 ++++++- internal/adapter/lsp/document.go | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 270788c..6ef1c4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,12 @@ All notable changes to this project will be documented in this file. - +## Unreleased + +### Fixed + +* [#126](https://github.com/mickael-menu/zk/issues/126) Embedded image links shown as not found. + ## 0.9.0 diff --git a/internal/adapter/lsp/document.go b/internal/adapter/lsp/document.go index 16dfd34..c38363e 100644 --- a/internal/adapter/lsp/document.go +++ b/internal/adapter/lsp/document.go @@ -218,6 +218,11 @@ func (d *document) DocumentLinks() ([]documentLink, error) { } for _, match := range markdownLinkRegex.FindAllStringSubmatchIndex(line, -1) { + // Ignore embedded image, e.g. ![title](href.png) + if match[0] > 0 && line[match[0]-1] == '!' { + continue + } + href := line[match[4]:match[5]] // Valid Markdown links are percent-encoded. if decodedHref, err := url.PathUnescape(href); err == nil {