branch: elpa/markdown-mode commit 92830999de663419970d2dee0b42d4fcc121cfd7 Merge: 847e7de1b1 b8637bae07 Author: Joe Reinhart <joseph.reinh...@gmail.com> Commit: Joe Reinhart <joseph.reinh...@gmail.com>
Merge branch 'master' into jayemar/toggle-hiding-of-wiki-links --- CHANGES.md | 10 ++++++++++ README.md | 5 ++--- markdown-mode.el | 37 ++++++++++++++++++------------------- tests/markdown-test.el | 44 +++++++++++++++++++++++++++++++++----------- 4 files changed, 63 insertions(+), 33 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 411102ba5a..50709e47bd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ variable `markdown-special-ctrl-a/e`, like Org mode. - Trailing whitespace characters for line breaks are hidden when using `markdown-hide-markup` + - `fill-paragraph` considers GFM alert syntax [GH-838][] * Bug fixes: - Don't highlight superscript/subscript in math inline/block [GH-802][] @@ -20,11 +21,16 @@ - Fix the regexp in the download languages script [GH-827][] - Don't hide backslashes in code blocks when using `markdown-hide-markup` and `markdown-fontify-code-blocks-natively` together [GH-766][] + - Fix `markdown-fontify-whole-heading-line` regression [GH-848][] * 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][] + - Change temporary buffer name according to the Emacs naming convention [GH-848][] + - Mark `markdown-css-paths` safe as file local variables [GH-834][] + - Resolve style sheets in `markdown-css-paths` relative to the Markdown file + [GH-855][] [gh-780]: https://github.com/jrblevin/markdown-mode/issues/780 [gh-802]: https://github.com/jrblevin/markdown-mode/issues/802 @@ -33,6 +39,10 @@ [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 + [gh-838]: https://github.com/jrblevin/markdown-mode/issues/838 + [gh-845]: https://github.com/jrblevin/markdown-mode/issues/845 + [gh-848]: https://github.com/jrblevin/markdown-mode/issues/848 + [gh-855]: https://github.com/jrblevin/markdown-mode/issues/855 # Markdown Mode 2.6 diff --git a/README.md b/README.md index 182141a0d3..f0b384243c 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ maintainer if not). * Ubuntu Linux: [elpa-markdown-mode][elpa-ubuntu] and [emacs-goodies-el][emacs-goodies-el-ubuntu] * RedHat and Fedora Linux: [emacs-goodies][] * NetBSD: [textproc/markdown-mode][] - * MacPorts: [markdown-mode.el][macports-package] ([pending][macports-ticket]) + * MacPorts: [markdown-mode.el][macports-package] * FreeBSD: [textproc/markdown-mode.el][freebsd-port] [elpa-markdown-mode]: https://packages.debian.org/sid/lisp/elpa-markdown-mode @@ -157,8 +157,7 @@ maintainer if not). [emacs-goodies-el-ubuntu]: http://packages.ubuntu.com/search?keywords=emacs-goodies-el [emacs-goodies]: https://apps.fedoraproject.org/packages/emacs-goodies [textproc/markdown-mode]: http://pkgsrc.se/textproc/markdown-mode - [macports-package]: https://trac.macports.org/browser/trunk/dports/editors/markdown-mode.el/Portfile - [macports-ticket]: http://trac.macports.org/ticket/35716 + [macports-package]: https://ports.macports.org/port/markdown-mode.el/ [freebsd-port]: http://svnweb.freebsd.org/ports/head/textproc/markdown-mode.el **Dependencies** diff --git a/markdown-mode.el b/markdown-mode.el index 71281607e8..149b07b13b 100644 --- a/markdown-mode.el +++ b/markdown-mode.el @@ -370,6 +370,7 @@ Math support can be enabled, disabled, or toggled later using (defcustom markdown-css-paths nil "List of URLs of CSS files to link to in the output XHTML." :group 'markdown + :safe (lambda (x) (and (listp x) (cl-every #'stringp x))) :type '(repeat (string :tag "CSS File Path"))) (defcustom markdown-content-type "text/html" @@ -3614,30 +3615,25 @@ SEQ may be an atom or a sequence." (add-text-properties (match-beginning 3) (match-end 3) rule-props))) ;; atx heading - (let ((header-end + (let ((fontified-start + (if (or markdown-hide-markup (not markdown-fontify-whole-heading-line)) + (match-beginning 5) + (match-beginning 0))) + (fontified-end (if markdown-fontify-whole-heading-line (min (point-max) (1+ (match-end 0))) - (match-end 0)))) + (match-end 5)))) (add-text-properties (match-beginning 4) (match-end 4) left-markup-props) ;; If closing tag is present (if (match-end 6) (progn - (if markdown-hide-markup - (progn - (add-text-properties - (match-beginning 5) header-end heading-props) - (add-text-properties - (match-beginning 6) (match-end 6) right-markup-props)) - (add-text-properties - (match-beginning 5) (match-end 5) heading-props) - (add-text-properties - (match-beginning 6) header-end right-markup-props))) + (add-text-properties fontified-start fontified-end heading-props) + (when (or markdown-hide-markup (not markdown-fontify-whole-heading-line)) + (add-text-properties (match-beginning 6) (match-end 6) right-markup-props))) ;; If closing tag is not present - (add-text-properties - (match-beginning 5) header-end heading-props)) - ))) + (add-text-properties fontified-start fontified-end heading-props))))) t)) (defun markdown-fontify-tables (last) @@ -7795,9 +7791,7 @@ Standalone XHTML output is identified by an occurrence of (defun markdown-stylesheet-link-string (stylesheet-path) (concat "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"" - (or (and (string-prefix-p "~" stylesheet-path) - (expand-file-name stylesheet-path)) - stylesheet-path) + (expand-file-name stylesheet-path) "\" />")) (defun markdown-escape-title (title) @@ -9232,7 +9226,7 @@ position." (remove-text-properties start end '(face nil)) (with-current-buffer (get-buffer-create - (concat " markdown-code-fontification:" (symbol-name lang-mode))) + (format " *markdown-code-fontification:%s*" (symbol-name lang-mode))) ;; Make sure that modification hooks are not inhibited in ;; the org-src-fontification buffer in case we're called ;; from `jit-lock-function' (Bug#25132). @@ -10398,6 +10392,11 @@ rows and columns and the column alignment." (setq markdown-link-space-sub-char "-") (setq markdown-wiki-link-search-subdirectories t) (setq-local markdown-table-at-point-p-function #'gfm--table-at-point-p) + (setq-local paragraph-separate + (concat paragraph-separate + "\\|" + ;; GFM alert syntax + "^>\s-*\\[!\\(?:NOTE\\|TIP\\|IMPORTANT\\|WARNING\\|CAUTION\\)\\]")) (add-hook 'post-self-insert-hook #'gfm--electric-pair-fence-code-block 'append t) (markdown-gfm-parse-buffer-for-languages)) diff --git a/tests/markdown-test.el b/tests/markdown-test.el index b1a881dcaa..9505e4a52c 100644 --- a/tests/markdown-test.el +++ b/tests/markdown-test.el @@ -3073,19 +3073,17 @@ puts markdown.to_html (let ((markdown-fontify-whole-heading-line t)) (let ((markdown-hide-markup nil)) (markdown-test-string "## abc \n" - (markdown-test-range-has-face 4 9 'markdown-header-face-2)) + (markdown-test-range-has-face 1 8 'markdown-header-face-2)) (markdown-test-string "## abc ##\n" - (markdown-test-range-has-face 4 6 'markdown-header-face-2) - (markdown-test-range-has-face 7 10 'markdown-header-delimiter-face))) + (markdown-test-range-has-face 1 9 'markdown-header-face-2))) (let ((markdown-hide-markup t)) (markdown-test-string "## abc \n" - (markdown-test-range-has-face 4 9 'markdown-header-face-2)) + (markdown-test-range-has-face 4 9 'markdown-header-face-2)) (markdown-test-string "## abc ##\n" - (markdown-test-range-has-face 4 6 'markdown-header-face-2) - (markdown-test-range-has-face 7 9 'markdown-header-delimiter-face) - (markdown-test-range-has-face 10 10 'markdown-header-face-2)) - ))) + (markdown-test-range-has-face 4 6 'markdown-header-face-2) + (markdown-test-range-has-face 7 9 'markdown-header-delimiter-face) + (markdown-test-range-has-face 10 10 'markdown-header-face-2))))) (ert-deftest test-markdown-font-lock/setext-1-letter () "An edge case for level-one setext headers." @@ -6109,6 +6107,16 @@ bar baz" (markdown-fill-paragraph) (should (string= (buffer-string) "- foo bar baz")))) +(ert-deftest test-markdown-filling/gfm-alert () + "Fill paragraph at GFM alert." + (let ((levels '("NOTE" "TIP" "IMPORTANT" "WARNING" "CAUTION")) + (template "> [!%s]\foo bar baz")) + (dolist (level levels) + (let ((input (format template level))) + (markdown-test-string-mode 'gfm-mode input + (markdown-fill-paragraph) + (should (string= (buffer-string) input))))))) + ;;; Export tests: (ert-deftest test-markdown-hook/xhtml-standalone () @@ -6176,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 (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)))))