branch: elpa/markdown-mode
commit 8aab017f4790f7a1e0d8403239cce989c88412f6
Merge: 0cdebc833e 55c8b23244
Author: Shohei YOSHIDA <syo...@gmail.com>
Commit: GitHub <nore...@github.com>

    Merge pull request #835 from jrblevin/issue-834
    
    Copy markdown-css-paths in the output buffer
---
 CHANGES.md             |  2 ++
 markdown-mode.el       | 78 +++++++++++++++++++++-----------------------------
 tests/markdown-test.el | 14 +++++++++
 3 files changed, 48 insertions(+), 46 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index d1fb3209e0..3236ad8d3b 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
 
diff --git a/markdown-mode.el b/markdown-mode.el
index 33f747612e..cba34f1d0e 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -684,52 +684,36 @@ 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 ==============================================
 
 ;; 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 =======================================================
@@ -7692,12 +7676,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