diff --git a/CHANGES.md b/CHANGES.md index d7a1d1ff..e97b0fd7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -28,6 +28,8 @@ - Show mode toggle message only if it is called interactively - Copy `markdown-css-paths` in the output buffer [GH-834][] - Change temporary buffer name according to the Emacs naming convention [GH-848][] + - Resolve style sheets in `markdown-css-paths` relative to the Markdown file + [GH-834][] [gh-780]: https://github.com/jrblevin/markdown-mode/issues/780 [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802 diff --git a/markdown-mode.el b/markdown-mode.el index 89d89629..2f9c5997 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -7735,9 +7735,7 @@ Standalone XHTML output is identified by an occurrence of (defun markdown-stylesheet-link-string (stylesheet-path) (concat "")) (defun markdown-escape-title (title) diff --git a/tests/markdown-test.el b/tests/markdown-test.el index f6be7d30..6fa5bf77 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 (file-name-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)))))