branch: elpa/markdown-mode
commit f0fa781d0a94796f0a65323b3271602ffd93c75c
Author: Shohei YOSHIDA <syo...@gmail.com>
Commit: Shohei YOSHIDA <syo...@gmail.com>

    Copy 'markdown-css-paths' to output buffer
---
 markdown-mode.el       | 14 ++++++++------
 tests/markdown-test.el | 14 ++++++++++++++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/markdown-mode.el b/markdown-mode.el
index c012f9d869..8dd28cd782 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -7692,12 +7692,14 @@ Return the name of the output buffer used."
 Insert the output in the buffer named OUTPUT-BUFFER-NAME."
   (interactive)
   (setq output-buffer-name (markdown output-buffer-name))
-  (with-current-buffer output-buffer-name
-    (set-buffer output-buffer-name)
-    (unless (markdown-output-standalone-p)
-      (markdown-add-xhtml-header-and-footer output-buffer-name))
-    (goto-char (point-min))
-    (html-mode))
+  (let ((css-path markdown-css-paths))
+    (with-current-buffer output-buffer-name
+      (set-buffer output-buffer-name)
+      (setq-local markdown-css-paths css-path)
+      (unless (markdown-output-standalone-p)
+        (markdown-add-xhtml-header-and-footer output-buffer-name))
+      (goto-char (point-min))
+      (html-mode)))
   output-buffer-name)
 
 (defun markdown-other-window (&optional output-buffer-name)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 21c7a033d6..abb90482af 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -6158,6 +6158,20 @@ bar baz"
       (kill-buffer obuffer)
       (delete-file ofile))))
 
+(ert-deftest test-markdown-export/buffer-local-css-path ()
+  "Test buffer local `markdown-css-paths'"
+  (let ((markdown-css-paths '("./global.css")))
+    (markdown-test-temp-file "inline.text"
+      (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\"")))
+        (kill-buffer buffer)
+        (delete-file file)))))
+
 ;;; Hook tests:
 
 (ert-deftest test-markdown-hook/before-export ()

Reply via email to