branch: elpa/markdown-mode
commit e3e11c40cc952e7996a7d1bba52b2ceb57f6fae7
Merge: 1716694217 28dad26e90
Author: Shohei YOSHIDA <syo...@gmail.com>
Commit: GitHub <nore...@github.com>

    Merge pull request #857 from mattiasb/feature/relative-css-paths
    
    Support relative paths in stylesheets
---
 CHANGES.md             |  3 +++
 markdown-mode.el       |  4 +---
 tests/markdown-test.el | 20 +++++++++++++++++---
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index ca732df009..50709e47bd 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -29,6 +29,8 @@
     - Copy `markdown-css-paths` in the output buffer [GH-834][]
     - 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][]
 
   [gh-780]: https://github.com/jrblevin/markdown-mode/issues/780
   [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802
@@ -40,6 +42,7 @@
   [gh-838]: https://github.com/jrblevin/markdown-mode/issues/838
   [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
 
 # Markdown Mode 2.6
 
diff --git a/markdown-mode.el b/markdown-mode.el
index 2152cd603b..414d5052be 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -7736,9 +7736,7 @@ 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=\""
-          (or (and (string-prefix-p "~" stylesheet-path)
-                   (expand-file-name stylesheet-path))
-              stylesheet-path)
+          (expand-file-name stylesheet-path)
           "\"  />"))
 
 (defun markdown-escape-title (title)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index f6be7d30aa..9505e4a52c 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -6184,15 +6184,29 @@ bar baz"
 
 (ert-deftest test-markdown-export/buffer-local-css-path ()
   "Test buffer local `markdown-css-paths'"
-  (let ((markdown-css-paths '("./global.css")))
+  (let ((markdown-css-paths '("/global.css")))
     (markdown-test-temp-file "inline.text"
-      (setq-local markdown-css-paths '("./local.css"))
+      (setq-local markdown-css-paths '("/local.css"))
       (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=\"./local.css\"")))
+          (should (search-forward "href=\"/local.css\"")))
+        (kill-buffer buffer)
+        (delete-file file)))))
+
+(ert-deftest test-markdown-export/relative-css-path ()
+  "Test relative `markdown-css-paths'."
+  (let ((markdown-css-paths '("style.css")))
+    (markdown-test-temp-file "inline.text"
+      (let* ((markdown-export-kill-buffer nil)
+             (file (markdown-export))
+             (buffer (get-file-buffer file))
+             (expanded-path (concat default-directory "style.css")))
+        (with-current-buffer buffer
+          (goto-char (point-min))
+          (should (search-forward (format "href=\"%s\"" expanded-path))))
         (kill-buffer buffer)
         (delete-file file)))))
 

Reply via email to