From 65fa685c7153bbaecb901d492f544774456534de Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Wed, 26 Jun 2024 11:56:58 +0900 Subject: [PATCH 1/4] untabify --- markdown-mode.el | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 33f74761..c012f9d8 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -684,18 +684,18 @@ This may also be a cons cell where the behavior for `C-a' and `C-e' is set separately." :group 'markdown :type '(choice - (const :tag "off" nil) - (const :tag "on: after hashes/bullet and before closing tags first" t) - (const :tag "reversed: true line boundary first" reversed) - (cons :tag "Set C-a and C-e separately" - (choice :tag "Special C-a" - (const :tag "off" nil) - (const :tag "on: after hashes/bullet first" t) - (const :tag "reversed: before hashes/bullet first" reversed)) - (choice :tag "Special C-e" - (const :tag "off" nil) - (const :tag "on: before closing tags first" t) - (const :tag "reversed: after closing tags first" reversed)))) + (const :tag "off" nil) + (const :tag "on: after hashes/bullet and before closing tags first" t) + (const :tag "reversed: true line boundary first" reversed) + (cons :tag "Set C-a and C-e separately" + (choice :tag "Special C-a" + (const :tag "off" nil) + (const :tag "on: after hashes/bullet first" t) + (const :tag "reversed: before hashes/bullet first" reversed)) + (choice :tag "Special C-e" + (const :tag "off" nil) + (const :tag "on: before closing tags first" t) + (const :tag "reversed: after closing tags first" reversed)))) :package-version '(markdown-mode . "2.7")) ;;; Markdown-Specific `rx' Macro ============================================== From f0fa781d0a94796f0a65323b3271602ffd93c75c Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Wed, 26 Jun 2024 15:04:09 +0900 Subject: [PATCH 2/4] 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 c012f9d8..8dd28cd7 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 21c7a033..abb90482 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 () From ba2beea3a381f5e96b04c75efeedfdb3a1abe264 Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Wed, 26 Jun 2024 15:18:32 +0900 Subject: [PATCH 3/4] Fix byte-compile warnings for emacs 30 or higher versions --- markdown-mode.el | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/markdown-mode.el b/markdown-mode.el index 8dd28cd7..cba34f1d 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -701,35 +701,19 @@ This may also be a cons cell where the behavior for `C-a' and ;;; Markdown-Specific `rx' Macro ============================================== ;; Based on python-rx from python.el. -(eval-and-compile - (defconst markdown-rx-constituents - `((newline . ,(rx "\n")) - ;; Note: #405 not consider markdown-list-indent-width however this is never used - (indent . ,(rx (or (repeat 4 " ") "\t"))) - (block-end . ,(rx (and (or (one-or-more (zero-or-more blank) "\n") line-end)))) - (numeral . ,(rx (and (one-or-more (any "0-9#")) "."))) - (bullet . ,(rx (any "*+:-"))) - (list-marker . ,(rx (or (and (one-or-more (any "0-9#")) ".") - (any "*+:-")))) - (checkbox . ,(rx "[" (any " xX") "]"))) - "Markdown-specific sexps for `markdown-rx'") - - (defun markdown-rx-to-string (form &optional no-group) - "Markdown mode specialized `rx-to-string' function. -This variant supports named Markdown expressions in FORM. -NO-GROUP non-nil means don't put shy groups around the result." - (let ((rx-constituents (append markdown-rx-constituents rx-constituents))) - (rx-to-string form no-group))) - - (defmacro markdown-rx (&rest regexps) - "Markdown mode specialized rx macro. +(defmacro markdown-rx (&rest regexps) + "Markdown mode specialized rx macro. This variant of `rx' supports common Markdown named REGEXPS." - (cond ((null regexps) - (error "No regexp")) - ((cdr regexps) - (markdown-rx-to-string `(and ,@regexps) t)) - (t - (markdown-rx-to-string (car regexps) t))))) + `(rx-let ((newline "\n") + ;; Note: #405 not consider markdown-list-indent-width however this is never used + (indent (or (repeat 4 " ") "\t")) + (block-end (and (or (one-or-more (zero-or-more blank) "\n") line-end))) + (numeral (and (one-or-more (any "0-9#")) ".")) + (bullet (any "*+:-")) + (list-marker (or (and (one-or-more (any "0-9#")) ".") + (any "*+:-"))) + (checkbox (seq "[" (any " xX") "]"))) + (rx ,@regexps))) ;;; Regular Expressions ======================================================= From 55c8b232441ec2cd604d95d5697f692b53967cc8 Mon Sep 17 00:00:00 2001 From: Shohei YOSHIDA Date: Wed, 26 Jun 2024 15:22:03 +0900 Subject: [PATCH 4/4] Update CHANGES --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index d1fb3209..3236ad8d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -22,6 +22,7 @@ * Improvements: - Apply url-unescape against URL in an inline link [GH-805][] - Show mode toggle message only if it is called interactively + - Copy `markdown-css-paths` in the output buffer [GH-834][] [gh-780]: https://github.com/jrblevin/markdown-mode/issues/780 [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802 @@ -29,6 +30,7 @@ [gh-805]: https://github.com/jrblevin/markdown-mode/issues/805 [gh-817]: https://github.com/jrblevin/markdown-mode/issues/817 [gh-827]: https://github.com/jrblevin/markdown-mode/issues/827 + [gh-834]: https://github.com/jrblevin/markdown-mode/issues/834 # Markdown Mode 2.6