Skip to content

Commit

Permalink
Copy 'markdown-css-paths' to output buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
syohex committed Jun 26, 2024
1 parent 65fa685 commit f0fa781
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
14 changes: 8 additions & 6 deletions markdown-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions tests/markdown-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down

0 comments on commit f0fa781

Please sign in to comment.