emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/markdown-mode 4810cac 2/2: Merge pull request #654 from jr


From: ELPA Syncer
Subject: [nongnu] elpa/markdown-mode 4810cac 2/2: Merge pull request #654 from jrblevin/issue-652
Date: Sat, 4 Sep 2021 03:57:31 -0400 (EDT)

branch: elpa/markdown-mode
commit 4810cac10355310ec76cd0946d0af92d595b3b81
Merge: a9cb230 ccb3a54
Author: Shohei YOSHIDA <syohex@gmail.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #654 from jrblevin/issue-652
    
    Support enable highlighting
---
 CHANGES.md             |  2 ++
 README.md              |  5 ++++-
 markdown-mode.el       | 28 ++++++++++++++++++++++++++++
 tests/markdown-test.el | 10 ++++++++++
 4 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index aa1aa9a..4cae4f4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -15,6 +15,7 @@
     -   Add `markdown-insert-foldable-block` function [GH-598][]
     -   Add `markdown-table-align-p` flag [GH-625][]
         Control table alignment after table operation
+    -   Support highlighting syntax like Obsidian, Quilt. [GH-652][]
 
 *   Improvements:
     -   Correct indirect buffer's indentation in `markdown-edit-code-block` 
[GH-375][]
@@ -113,6 +114,7 @@
   [gh-640]: https://github.com/jrblevin/markdown-mode/issues/640
   [gh-641]: https://github.com/jrblevin/markdown-mode/issues/641
   [gh-649]: https://github.com/jrblevin/markdown-mode/issues/649
+  [gh-652]: https://github.com/jrblevin/markdown-mode/issues/652
 
 # Markdown Mode 2.4
 
diff --git a/README.md b/README.md
index b3c21c3..342e1de 100644
--- a/README.md
+++ b/README.md
@@ -907,6 +907,9 @@ provides an interface to all of the possible customizations:
     `markdown-insert-list-item` inserts enumerated numbers for
     ordered list marker. While nil, it always inserts `1.`.
 
+  * `markdown-enable-highlighting-syntax` - font lock for highlighting
+     syntax like Obsidian, Quilt(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
@@ -992,7 +995,7 @@ by `markdown-mode` and `gfm-mode` as described below.
   region will be placed inside the code block.  You will be
   prompted for the name of the language, but may press enter to
   continue without naming a language.
-  
+
   In addition, in `gfm-mode`, GFM code blocks can be inserted via the
   option `markdown-gfm-use-electric-backquote`. If the option
   `markdown-code-block-braces` is set to `t`, code blocks inserted with
diff --git a/markdown-mode.el b/markdown-mode.el
index 5db1068..9c52cd3 100644
--- a/markdown-mode.el
+++ b/markdown-mode.el
@@ -347,6 +347,13 @@ Math support can be enabled, disabled, or toggled later 
using
   :safe 'booleanp
   :package-version '(markdown-mode . "2.4"))
 
+(defcustom markdown-enable-highlighting-syntax nil
+  "Enable highlighting syntax."
+  :group 'markdown
+  :type 'boolean
+  :safe 'booleanp
+  :package-version '(markdown-mode . "2.5"))
+
 (defcustom markdown-css-paths nil
   "List of URLs of CSS files to link to in the output XHTML."
   :group 'markdown
@@ -1043,6 +1050,15 @@ Group 3 matches all attributes and whitespace following 
the tag name.")
   "\\(&#?[[:alnum:]]+;\\)"
   "Regular expression for matching HTML entities.")
 
+(defconst markdown-regex-highlighting
+  "\\(?1:^\\|[^\\]\\)\\(?2:\\(?3:==\\)\\(?4:[^ \n\t\\]\\|[^ 
\n\t]\\(?:.\\|\n[^\n]\\)*?[^\\ ]\\)\\(?5:==\\)\\)"
+"Regular expression for matching highlighting text.
+Group 1 matches the character before the opening equal, if any,
+ensuring that it is not a backslash escape.
+Group 2 matches the entire expression, including delimiters.
+Groups 3 and 5 matches the opening and closing delimiters.
+Group 4 matches the text inside the delimiters.")
+
 
 ;;; Syntax ====================================================================
 
@@ -1979,6 +1995,11 @@ For example, this applies to plain angle bracket URLs:
   "Face for HTML entities."
   :group 'markdown-faces)
 
+(defface markdown-highlighting-face
+  '((t (:background "yellow" :foreground "black")))
+  "Face for highlighting."
+  :group 'markdown-faces)
+
 (defcustom markdown-header-scaling nil
   "Whether to use variable-height faces for headers.
 When non-nil, `markdown-header-face' will inherit from
@@ -2171,6 +2192,9 @@ Depending on your font, some reasonable choices are:
     (,markdown-regex-strike-through . ((3 markdown-markup-properties)
                                        (4 'markdown-strike-through-face)
                                        (5 markdown-markup-properties)))
+    (markdown--match-highlighting . ((3 markdown-markup-properties)
+                                     (4 'markdown-highlighting-face)
+                                     (5 markdown-markup-properties)))
     (,markdown-regex-line-break . (1 'markdown-line-break-face prepend))
     (markdown-fontify-sub-superscripts)
     (markdown-match-inline-attributes . ((0 markdown-markup-properties 
prepend)))
@@ -2891,6 +2915,10 @@ When FACELESS is non-nil, do not return matches where 
faces have been applied."
                                 (match-beginning 4) (match-end 4)))
           t)))))
 
+(defun markdown--match-highlighting (last)
+  (when markdown-enable-highlighting-syntax
+    (re-search-forward markdown-regex-highlighting last t)))
+
 (defun markdown-match-math-generic (regex last)
   "Match REGEX from point to LAST.
 REGEX is either `markdown-regex-math-inline-single' for matching
diff --git a/tests/markdown-test.el b/tests/markdown-test.el
index cbc1bbc..67cf3a1 100644
--- a/tests/markdown-test.el
+++ b/tests/markdown-test.el
@@ -3561,6 +3561,16 @@ across blocks]"
     (markdown-test-range-has-face 29 37 'markdown-html-attr-value-face)
     (markdown-test-range-has-face 38 38 'markdown-html-tag-delimiter-face)))
 
+(ert-deftest test-markdown-font-lock/highlighting-syntax ()
+  "Test highlighting syntax ==foo==."
+  (let ((markdown-enable-highlighting-syntax t))
+    (markdown-test-string "==foo=="
+      (markdown-test-range-has-face 1 2 'markdown-markup-face)
+      (markdown-test-range-has-face 3 5 'markdown-highlighting-face)
+      (markdown-test-range-has-face 6 7 'markdown-markup-face)))
+  (markdown-test-string "==foo=="
+    (markdown-test-range-has-face 1 7 nil)))
+
 ;;; Markdown Parsing Functions:
 
 (ert-deftest test-markdown-parsing/extend-region-function ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]