emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode fc729ea 2/8: WIP: fix+add tests for markdown


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode fc729ea 2/8: WIP: fix+add tests for markdown-do link jump
Date: Thu, 21 Oct 2021 20:57:50 -0400 (EDT)

branch: elpa/markdown-mode
commit fc729ea1d5b50730484a019ac5d3894b5bfb90c5
Author: Eric Drechsel <eric@pdxhub.org>
Commit: Eric Drechsel <eric@pdxhub.org>

    WIP: fix+add tests for markdown-do link jump
---
 markdown-mode.el       |  6 +++---
 tests/markdown-test.el | 27 +++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/markdown-mode.el b/markdown-mode.el
index 64acb15..2dc3a97 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -8222,9 +8222,6 @@ Jumps between reference links and definitions; between 
footnote
 markers and footnote text."
   (interactive)
   (cond
-   ;; Link
-   ((or (markdown-link-p) (markdown-wiki-link-p))
-    (markdown-follow-thing-at-point nil))
    ;; Footnote definition
    ((markdown-footnote-text-positions)
     (markdown-footnote-return))
@@ -8237,6 +8234,9 @@ markers and footnote text."
    ;; Reference definition
    ((thing-at-point-looking-at markdown-regex-reference-definition)
     (markdown-reference-goto-link (match-string-no-properties 2)))
+   ;; Link
+   ((or (markdown-link-p) (markdown-wiki-link-p))
+    (markdown-follow-thing-at-point nil))
    ;; GFM task list item
    ((markdown-gfm-task-list-item-at-point)
     (markdown-toggle-gfm-checkbox))
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 67cf3a1..f0a08fd 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -1558,6 +1558,33 @@ the opening bracket of [^2], and then subsequent 
functions would kill [^2])."
       (markdown-footnote-kill)
       (should (string-equal (current-kill 0) "foo\n")))))
 
+(ert-deftest test-markdown-do/jump-wikilink ()
+  "Test `markdown-do' jumps to wiki links"
+  (markdown-test-string
+      "[[Foo]]"
+    (goto-char 3) ; Foo
+    (markdown-do) ; open Foo.md
+    (should (string= (buffer-string) ""))))
+
+(ert-deftest test-markdown-do/jump-link ()
+  "Test `markdown-do' jumps to markdown links"
+  (markdown-test-string
+      "[bar](https://duckduckgo.com)"
+    (goto-char 3) ; Foo
+    (markdown-do) ; open browser
+    (should (string= (buffer-string) ""))))
+
+(ert-deftest test-markdown-do/wikilink-in-table ()
+  "Test `markdown-do' jumps to markdown links"
+  (markdown-test-string
+      "| [[Foo]]     |"
+    (goto-char 1) ; Table cell
+    (markdown-do) ; align
+    (should (string= (buffer-string) "| [[Foo]] |"))
+    (goto-char 4) ; Foo
+    (markdown-do) ; open Foo.md
+    (should (string= (buffer-string) "| [[Foo]] |"))))
+
 (ert-deftest test-markdown-footnote-reference/jump ()
   "Test `markdown-do' for footnotes and reference links."
   (markdown-test-string



reply via email to

[Prev in Thread] Current Thread [Next in Thread]