From f03477af11476c42cf18d9db414a1c9c1c3f9eb9 Mon Sep 17 00:00:00 2001 From: anarcat Date: Thu, 15 Mar 2018 14:26:38 -0400 Subject: [PATCH 1/2] skip empty URLs when inlining images Markdown links like `[foo]()`, while basically invalid, do not usually cause too much trouble, or at least shouldn't cause problems in unrelated code. It so happens that if a document happens to have such a link, `markdown-toggle-inline-images` will crash with: insert-file-contents-literally: not a regular file: /tmp/default-directory-path/ This patch fixes the problem by checking if the `file` path extracted from the regex is empty before proceeding with treating it like an image. --- markdown-mode.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/markdown-mode.el b/markdown-mode.el index 790b5a24..e67bb337 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -8376,7 +8376,8 @@ or \\[markdown-toggle-inline-images]." (let ((start (match-beginning 0)) (end (match-end 0)) (file (match-string-no-properties 6))) - (when (file-exists-p file) + (when (and (not (zerop (length file))) + (file-exists-p file)) (let* ((abspath (if (file-name-absolute-p file) file (concat default-directory file))) From 77d3ed5d72ba3aec2e569edcd0c3c7fb911ace24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= Date: Thu, 15 Mar 2018 14:31:13 -0400 Subject: [PATCH 2/2] add CHANGES entry --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 76b5eba8..29be3a85 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -101,6 +101,7 @@ - Fix precedence of inline code over inline links. - Improve error reporting for `markdown` and `markdown-open`. ([GH-291][]) + - Do not fail displaying inline images on empty links [gh-171]: https://github.com/jrblevin/markdown-mode/issues/171 [gh-216]: https://github.com/jrblevin/markdown-mode/issues/216