From 3898a12063c9701fcfddb576141fb971b2391594 Mon Sep 17 00:00:00 2001 From: Mattias Bengtsson Date: Wed, 8 Jan 2025 23:26:14 +0100 Subject: [PATCH] Make it possible to use style sheet URLs again Only expand `markdown-css-paths` that clearly are relative. This disables the *unreleased* support for relative paths without a "./", "../" or "~" prefix. Add an extra `markdown-css-paths` test that ensures we don't break URL support going forward. Fixes #869. --- markdown-mode.el | 4 +++- tests/markdown-test.el | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 99c61cb7..a2626231 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -7736,7 +7736,9 @@ 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 9505e4a5..c62392e1 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -6182,6 +6182,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"))) @@ -6198,7 +6211,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))