branch: elpa/markdown-mode
commit 5bebb44f7ff29332839e7a79a2c6c0487b3935b9
Merge: 06b15337c9 e100778594
Author: Joe Reinhart <joseph.reinh...@gmail.com>
Commit: Joe Reinhart <joseph.reinh...@gmail.com>

    Pull in latest from master
---
 CHANGES.md             |   3 +-
 README.md              |   7 +-
 markdown-mode.el       |   4 +-
 tests/markdown-test.el | 227 ++++++++++++++++++++++++++-----------------------
 4 files changed, 128 insertions(+), 113 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 50709e47bd..55e63f647d 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -30,7 +30,7 @@
     - Change temporary buffer name according to the Emacs naming convention 
[GH-848][]
     - Mark `markdown-css-paths` safe as file local variables [GH-834][]
     - Resolve style sheets in `markdown-css-paths` relative to the Markdown 
file
-      [GH-855][]
+      (if the path starts with `./` or `../`) [GH-855][] [GH-870][]
 
   [gh-780]: https://github.com/jrblevin/markdown-mode/issues/780
   [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802
@@ -43,6 +43,7 @@
   [gh-845]: https://github.com/jrblevin/markdown-mode/issues/845
   [gh-848]: https://github.com/jrblevin/markdown-mode/issues/848
   [gh-855]: https://github.com/jrblevin/markdown-mode/issues/855
+  [gh-870]: https://github.com/jrblevin/markdown-mode/issues/870
 
 # Markdown Mode 2.6
 
diff --git a/README.md b/README.md
index 41675ed989..b6bd29823a 100644
--- a/README.md
+++ b/README.md
@@ -178,8 +178,7 @@ tend to be associated with paired delimiters such as 
<kbd>M-{</kbd> and
 <kbd>M-}</kbd> or <kbd>C-c <</kbd> and <kbd>C-c ></kbd>.  Outline navigation 
keybindings the
 same as in `org-mode`.  Finally, commands for running Markdown or
 doing maintenance on an open file are grouped under the <kbd>C-c C-c</kbd>
-prefix.  The most commonly used commands are described below. You
-can obtain a list of all keybindings by pressing <kbd>C-c C-h</kbd>.
+prefix.  The most commonly used commands are described below.
 
   * Links and Images: <kbd>C-c C-l</kbd> and <kbd>C-c C-i</kbd>
 
@@ -1086,13 +1085,13 @@ by `markdown-mode` and `gfm-mode` as described below.
     ```
 
 * **Preview:** GFM-specific preview can be powered by setting
-  `markdown-command` to use [Docter][].  This may also be
+  `markdown-command` to use [marked][].  This may also be
   configured to work with [Marked 2][] for `markdown-open-command`.
 
 [GFM]: http://github.github.com/github-flavored-markdown/
 [GFM comments]: https://help.github.com/articles/writing-on-github/
 [since 2014]: https://github.com/blog/1825-task-lists-in-all-markdown-documents
-[Docter]: https://github.com/alampros/Docter
+[marked]: https://marked.js.org/
 
 ## Acknowledgments
 
diff --git a/markdown-mode.el b/markdown-mode.el
index c081cb106b..a7c36b1276 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -7742,7 +7742,9 @@ Standalone XHTML output is identified by an occurrence of
 
 (defun markdown-stylesheet-link-string (stylesheet-path)
   (concat "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\""
-          (expand-file-name stylesheet-path)
+          (or (and (string-match-p (rx (or "~" "./" "../")) stylesheet-path)
+                   (expand-file-name stylesheet-path))
+              stylesheet-path)
           "\"  />"))
 
 (defun markdown-escape-title (title)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index b13eb87f6e..5b0c825388 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -5761,112 +5761,6 @@ http://example.com \"title\"  )
         (call-interactively 'markdown-kill-thing-at-point)
         (should (string-equal (current-kill 0) (cdr test)))))))
 
-(ert-deftest test-markdown/wiki-link-rules ()
-  "Test wiki link search rules and font lock for missing pages."
-  (let ((markdown-enable-wiki-links t)
-        (markdown-wiki-link-fontify-missing t)
-        (markdown-wiki-link-search-type '(project)))
-    (progn
-      (find-file (expand-file-name "wiki/root" markdown-test-dir))
-      (unwind-protect
-          (progn
-            (markdown-mode)
-            (font-lock-ensure)
-            ;; search rules
-            (should (string-match-p
-                     "/sub/foo$"
-                     (markdown-convert-wiki-link-to-filename "foo")))
-            (should (string-equal
-                     (markdown-convert-wiki-link-to-filename "doesnotexist")
-                     "doesnotexist"))
-            ;; font lock
-            (markdown-test-range-has-property  1  2 'face 
'markdown-markup-face)
-            (markdown-test-range-has-property  3  9 'face 'markdown-link-face)
-            (markdown-test-range-has-property 10 11 'face 
'markdown-markup-face)
-            (markdown-test-range-has-property 16 31 'face 
'markdown-missing-link-face)
-            (markdown-test-range-has-property 38 40 'face 'markdown-link-face)
-            (markdown-test-range-has-property 47 58 'face 
'markdown-missing-link-face)
-            (markdown-test-range-has-property 65 74 'face 'markdown-link-face))
-        (kill-buffer)))
-    (progn
-      (find-file (expand-file-name "wiki/sub/foo" markdown-test-dir))
-      (unwind-protect
-          (progn
-            (markdown-mode)
-            (font-lock-ensure)
-            ;; search rules
-            (should (string-match-p
-                     "/wiki/root$"
-                     (markdown-convert-wiki-link-to-filename "root")))
-            (should (string-equal
-                     (markdown-convert-wiki-link-to-filename "doesnotexist")
-                     "doesnotexist"))
-            ;; font lock
-            (markdown-test-range-has-property  3 14 'face 
'markdown-missing-link-face)
-            (markdown-test-range-has-property 21 24 'face 'markdown-link-face))
-        (kill-buffer)))))
-
-(ert-deftest test-markdown/wiki-link-keep-match-data ()
-  "Test that markdown-wiki-link-p keeps expected match data.
-Detail: https://github.com/jrblevin/markdown-mode/pull/590";
-  (let ((markdown-enable-wiki-links t)
-        (markdown-link-space-sub-char " ")
-        (markdown-wiki-link-search-type '(sub-directories)))
-    (progn
-      (find-file (expand-file-name "wiki/pr590/Guide.md" markdown-test-dir))
-      (unwind-protect
-          (progn
-            (markdown-mode)
-            (re-search-forward "Zettel Markdown")
-            (goto-char (match-beginning 0))
-            (should (markdown-wiki-link-p)) ;; create match-data
-            (should (string= (markdown-wiki-link-link) "Zettel Markdown")))
-        (kill-buffer)))))
-
-(ert-deftest test-markdown/wiki-link-search-under-project ()
-  "Test that searching link under project root."
-  (let ((markdown-enable-wiki-links t)
-        (markdown-link-space-sub-char " ")
-        (markdown-wiki-link-search-type '(project))
-        (expected (expand-file-name "wiki/pr590/Guide/Zettel Markdown/math.md"
-                                    markdown-test-dir)))
-    (progn
-      (find-file (expand-file-name "wiki/pr590/Guide/Plugin/Link.md" 
markdown-test-dir))
-      (unwind-protect
-          (progn
-            (markdown-mode)
-            (re-search-forward "math")
-            (goto-char (match-beginning 0))
-            (markdown-wiki-link-p) ;; create match-data
-            (let ((link (markdown-convert-wiki-link-to-filename 
(markdown-wiki-link-link))))
-              (should (string= (expand-file-name link) expected))))
-        (kill-buffer)))))
-
-(ert-deftest test-markdown/wiki-link-major-mode ()
-  "Test major-mode of linked page."
-  (let ((markdown-enable-wiki-links t)
-        (auto-mode-alist (cons '("bar\\.md" . gfm-mode) auto-mode-alist)))
-    (find-file (expand-file-name "wiki/root" markdown-test-dir))
-    (unwind-protect
-        (progn
-          (markdown-mode)
-          (search-forward "sub/bar.md")
-          (markdown-follow-wiki-link-at-point)
-          (should (eq major-mode 'gfm-mode)))
-      (kill-buffer))))
-
-(ert-deftest test-markdown/wiki-link-nonexistent-file ()
-  "Test following wiki link to nonexistent file visits the buffer."
-  (let ((markdown-enable-wiki-links t))
-    (find-file (expand-file-name "wiki/foo.md" markdown-test-dir))
-    (unwind-protect
-        (progn
-          (markdown-mode)
-          (search-forward "[[doesnotexist]]")
-          (markdown-follow-wiki-link-at-point)
-          (should (string= (buffer-name) "doesnotexist.md")))
-      (kill-buffer))))
-
 ;;; Filling tests:
 
 (ert-deftest test-markdown-filling/blockquote ()
@@ -6273,6 +6167,19 @@ bar baz"
       (kill-buffer obuffer)
       (delete-file ofile))))
 
+(ert-deftest test-markdown-export/url-css-path ()
+  "Test `markdown-css-paths' as URL."
+  (let ((markdown-css-paths '("http://www.example.com/style.css";)))
+    (markdown-test-temp-file "inline.text"
+      (let* ((markdown-export-kill-buffer nil)
+             (file (markdown-export))
+             (buffer (get-file-buffer file)))
+        (with-current-buffer buffer
+          (goto-char (point-min))
+          (should (search-forward 
"href=\"http://www.example.com/style.css\"";)))
+        (kill-buffer buffer)
+        (delete-file file)))))
+
 (ert-deftest test-markdown-export/buffer-local-css-path ()
   "Test buffer local `markdown-css-paths'"
   (let ((markdown-css-paths '("/global.css")))
@@ -6289,7 +6196,7 @@ bar baz"
 
 (ert-deftest test-markdown-export/relative-css-path ()
   "Test relative `markdown-css-paths'."
-  (let ((markdown-css-paths '("style.css")))
+  (let ((markdown-css-paths '("./style.css")))
     (markdown-test-temp-file "inline.text"
       (let* ((markdown-export-kill-buffer nil)
              (file (markdown-export))
@@ -7125,6 +7032,112 @@ x|"
     (markdown-indent-region (line-beginning-position) (line-end-position) nil)
     (should (string-equal (buffer-string) " #. abc\n    def\n"))))
 
+(ert-deftest test-markdown/wiki-link-rules ()
+  "Test wiki link search rules and font lock for missing pages."
+  (let ((markdown-enable-wiki-links t)
+        (markdown-wiki-link-fontify-missing t)
+        (markdown-wiki-link-search-type '(project)))
+    (progn
+      (find-file (expand-file-name "wiki/root" markdown-test-dir))
+      (unwind-protect
+          (progn
+            (markdown-mode)
+            (font-lock-ensure)
+            ;; search rules
+            (should (string-match-p
+                     "/sub/foo$"
+                     (markdown-convert-wiki-link-to-filename "foo")))
+            (should (string-equal
+                     (markdown-convert-wiki-link-to-filename "doesnotexist")
+                     "doesnotexist"))
+            ;; font lock
+            (markdown-test-range-has-property  1  2 'face 
'markdown-markup-face)
+            (markdown-test-range-has-property  3  9 'face 'markdown-link-face)
+            (markdown-test-range-has-property 10 11 'face 
'markdown-markup-face)
+            (markdown-test-range-has-property 16 31 'face 
'markdown-missing-link-face)
+            (markdown-test-range-has-property 38 40 'face 'markdown-link-face)
+            (markdown-test-range-has-property 47 58 'face 
'markdown-missing-link-face)
+            (markdown-test-range-has-property 65 74 'face 'markdown-link-face))
+        (kill-buffer)))
+    (progn
+      (find-file (expand-file-name "wiki/sub/foo" markdown-test-dir))
+      (unwind-protect
+          (progn
+            (markdown-mode)
+            (font-lock-ensure)
+            ;; search rules
+            (should (string-match-p
+                     "/wiki/root$"
+                     (markdown-convert-wiki-link-to-filename "root")))
+            (should (string-equal
+                     (markdown-convert-wiki-link-to-filename "doesnotexist")
+                     "doesnotexist"))
+            ;; font lock
+            (markdown-test-range-has-property  3 14 'face 
'markdown-missing-link-face)
+            (markdown-test-range-has-property 21 24 'face 'markdown-link-face))
+        (kill-buffer)))))
+
+(ert-deftest test-markdown/wiki-link-keep-match-data ()
+  "Test that markdown-wiki-link-p keeps expected match data.
+Detail: https://github.com/jrblevin/markdown-mode/pull/590";
+  (let ((markdown-enable-wiki-links t)
+        (markdown-link-space-sub-char " ")
+        (markdown-wiki-link-search-type '(sub-directories)))
+    (progn
+      (find-file (expand-file-name "wiki/pr590/Guide.md" markdown-test-dir))
+      (unwind-protect
+          (progn
+            (markdown-mode)
+            (re-search-forward "Zettel Markdown")
+            (goto-char (match-beginning 0))
+            (should (markdown-wiki-link-p)) ;; create match-data
+            (should (string= (markdown-wiki-link-link) "Zettel Markdown")))
+        (kill-buffer)))))
+
+(ert-deftest test-markdown/wiki-link-search-under-project ()
+  "Test that searching link under project root."
+  (let ((markdown-enable-wiki-links t)
+        (markdown-link-space-sub-char " ")
+        (markdown-wiki-link-search-type '(project))
+        (expected (expand-file-name "wiki/pr590/Guide/Zettel Markdown/math.md"
+                                    markdown-test-dir)))
+    (progn
+      (find-file (expand-file-name "wiki/pr590/Guide/Plugin/Link.md" 
markdown-test-dir))
+      (unwind-protect
+          (progn
+            (markdown-mode)
+            (re-search-forward "math")
+            (goto-char (match-beginning 0))
+            (markdown-wiki-link-p) ;; create match-data
+            (let ((link (markdown-convert-wiki-link-to-filename 
(markdown-wiki-link-link))))
+              (should (string= (expand-file-name link) expected))))
+        (kill-buffer)))))
+
+(ert-deftest test-markdown/wiki-link-major-mode ()
+  "Test major-mode of linked page."
+  (let ((markdown-enable-wiki-links t)
+        (auto-mode-alist (cons '("bar\\.md" . gfm-mode) auto-mode-alist)))
+    (find-file (expand-file-name "wiki/root" markdown-test-dir))
+    (unwind-protect
+        (progn
+          (markdown-mode)
+          (search-forward "sub/bar.md")
+          (markdown-follow-wiki-link-at-point)
+          (should (eq major-mode 'gfm-mode)))
+      (kill-buffer))))
+
+(ert-deftest test-markdown/wiki-link-nonexistent-file ()
+  "Test following wiki link to nonexistent file visits the buffer."
+  (let ((markdown-enable-wiki-links t))
+    (find-file (expand-file-name "wiki/foo.md" markdown-test-dir))
+    (unwind-protect
+        (progn
+          (markdown-mode)
+          (search-forward "[[doesnotexist]]")
+          (markdown-follow-wiki-link-at-point)
+          (should (string= (buffer-name) "doesnotexist.md")))
+      (kill-buffer))))
+
 (defun markdown-test-live-preview-window-eww (_orig-fun &rest _args)
   (get-buffer-create "*eww*"))
 

Reply via email to