[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/markdown-mode add76118e6 1/2: Introduce markdown-fontify-w
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/markdown-mode add76118e6 1/2: Introduce markdown-fontify-whole-heading-line |
Date: |
Sun, 8 May 2022 08:58:27 -0400 (EDT) |
branch: elpa/markdown-mode
commit add76118e6056eb23a779ebd561919cff668e9ed
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: Shohei YOSHIDA <syohex@gmail.com>
Introduce markdown-fontify-whole-heading-line
This is same as org-fontify-whole-heading-line
---
CHANGES.md | 6 ++++++
README.md | 5 ++++-
markdown-mode.el | 25 +++++++++++++++++++------
tests/markdown-test.el | 8 ++++++++
4 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 920ceb639d..da1f7d795f 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -5,11 +5,17 @@
* **Breaking changes:**
- GNU Emacs 26.1 or later is required.
+* New Feature:
+ - Introduce `markdown-fontify-whole-heading-line` variable for highlighting
+ whole header line. [GH-705][]
+
* Improvements:
- `markdown` passes `buffer-file-name` as a parameter to
`markdown-command` when `markdown-command-needs-filename` is
`t` and `markdown-command` is a function.
+ [gh-705]: https://github.com/jrblevin/markdown-mode/issues/705
+
# Markdown Mode 2.5
* **Breaking changes:**
diff --git a/README.md b/README.md
index 6f9520b7aa..1fc96732c7 100644
--- a/README.md
+++ b/README.md
@@ -683,7 +683,7 @@ provides an interface to all of the possible customizations:
When set to `t`, `markdown-mode` will pass the name of the file
as the final command-line argument to `markdown-command`. Note
that in the latter case, you will only be able to run
- `markdown-command` from buffers which are visiting a file.
+ `markdown-command` from buffers which are visiting a file.
* `markdown-open-command` - the command used for calling a standalone
Markdown previewer which is capable of opening Markdown source files
@@ -914,6 +914,9 @@ provides an interface to all of the possible customizations:
* `markdown-enable-highlighting-syntax` - font lock for highlighting
syntax like Obsidian, Quilt(default: `nil`).
+ * `markdown-fontify-whole-heading-line` - font lock for highlighting
+ the whole line for headings.(default: `nil`)
+
Additionally, the faces used for syntax highlighting can be modified to
your liking by issuing <kbd>M-x customize-group RET markdown-faces</kbd>
or by using the "Markdown Faces" link at the bottom of the mode
diff --git a/markdown-mode.el b/markdown-mode.el
index 9df4c034ee..3eca261e66 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -637,6 +637,15 @@ This variable must be set before loading markdown-mode."
:safe 'booleanp
:package-version '(markdown-mode . "2.5"))
+(defcustom markdown-fontify-whole-heading-line nil
+ "Non-nil means fontify the whole line for headings.
+This is useful when setting a background color for the
+markdown-header-face-* faces."
+ :group 'markdown
+ :type 'boolean
+ :safe 'booleanp
+ :package-version '(markdown-mode . "2.5"))
+
;;; Markdown-Specific `rx' Macro ==============================================
@@ -3426,13 +3435,17 @@ SEQ may be an atom or a sequence."
(add-text-properties
(match-beginning 3) (match-end 3) rule-props)))
;; atx heading
- (add-text-properties
- (match-beginning 4) (match-end 4) left-markup-props)
- (add-text-properties
- (match-beginning 5) (match-end 5) heading-props)
- (when (match-end 6)
+ (if markdown-fontify-whole-heading-line
+ (let ((header-end (min (point-max) (1+ (match-end 0)))))
+ (add-text-properties
+ (match-beginning 0) header-end heading-props))
(add-text-properties
- (match-beginning 6) (match-end 6) right-markup-props))))
+ (match-beginning 4) (match-end 4) left-markup-props)
+ (add-text-properties
+ (match-beginning 5) (match-end 5) heading-props)
+ (when (match-end 6)
+ (add-text-properties
+ (match-beginning 6) (match-end 6) right-markup-props)))))
t))
(defun markdown-fontify-tables (last)
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index 50b0e8043a..49cd5be24a 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -2948,6 +2948,14 @@ puts markdown.to_html
(markdown-test-string "###"
(markdown-test-range-has-face 1 3 nil)))
+(ert-deftest test-markdown-font-lock/atx-whole-line ()
+ "Test font-lock for atx headers with whole line flag."
+ (let ((markdown-fontify-whole-heading-line t))
+ (markdown-test-string "## abc "
+ (markdown-test-range-has-face 1 8 'markdown-header-face-2))
+ (markdown-test-string "## abc ##"
+ (markdown-test-range-has-face 1 9 'markdown-header-face-2))))
+
(ert-deftest test-markdown-font-lock/setext-1-letter ()
"An edge case for level-one setext headers."
(markdown-test-string "a\n=\n"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/markdown-mode add76118e6 1/2: Introduce markdown-fontify-whole-heading-line,
ELPA Syncer <=