[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/adoc-mode e36c0105ab 104/199: improved fontifying for foot
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/adoc-mode e36c0105ab 104/199: improved fontifying for footnotes |
Date: |
Sun, 3 Sep 2023 06:59:38 -0400 (EDT) |
branch: elpa/adoc-mode
commit e36c0105ab3778ddcd728b8b876364798b9e9a09
Author: sensorflo <sensorflo@gmail.com>
Commit: sensorflo <sensorflo@gmail.com>
improved fontifying for footnotes
---
adoc-mode-test.el | 20 ++++++++++++++
adoc-mode.el | 79 +++++++++++++++++++++++++++++--------------------------
2 files changed, 62 insertions(+), 37 deletions(-)
diff --git a/adoc-mode-test.el b/adoc-mode-test.el
index 16966854bf..b412a913fa 100644
--- a/adoc-mode-test.el
+++ b/adoc-mode-test.el
@@ -289,6 +289,26 @@ removed before TRANSFORM is evaluated.
"bla bli bla blu" markup-reference-face "]" markup-meta-face
))
+(ert-deftest adoctest-test-footnotes ()
+ (adoctest-faces "footnotes"
+ ;; simple example
+ "footnote" markup-command-face ":" markup-meta-face
+ "[" markup-meta-face "lorem ipsum" markup-secondary-text-face
+ "]" markup-meta-face "\n" nil
+
+ ;; footnote can be hard up against the preceding word
+ "lorem" 'no-face "footnote" markup-command-face ":" markup-meta-face
+ "[" markup-meta-face "ipsum" markup-secondary-text-face
+ "]" markup-meta-face "\n" nil
+
+ ;; attribute-list is not really an attribute list but normal text,
+ ;; i.e. comma, equal, double quotes are not fontified as meta characters
+ "footnote" markup-command-face ":" markup-meta-face
+ "[" markup-meta-face
+ "lorem, ipsum=dolor, sit=\"amen\"" markup-secondary-text-face
+ "]" markup-meta-face "\n" nil
+ ))
+
(ert-deftest adoctest-test-images ()
(adoctest-faces "images"
;; block macros
diff --git a/adoc-mode.el b/adoc-mode.el
index c5a01e0e4d..575606451b 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -1314,27 +1314,34 @@ text having adoc-reserved set to 'block-del."
;; opposed to named attributes, thus init with 0.
(pos-or-name-of-attribute 0))
- ;; for each attribute in current attribute list
- (while (re-search-forward (adoc-re-attribute-list-elt)
attribute-list-end t)
- (when (match-beginning 1); i.e. when it'a named attribute
- ;; get attribute's name
- (setq pos-or-name-of-attribute
- (buffer-substring-no-properties (match-beginning 1)
(match-end 1)))
- ;; fontify the attribute's name with markup-attribute-face
+ (if (eq 'entire-attribute-list prop-of-attribute-list)
+ ;; The attribute list is not really an attribute list. As a whole
+ ;; it counts as text.
(put-text-property
- (match-beginning 1) (match-end 1) 'face markup-attribute-face))
-
- ;; fontify the attribute's value
- (let ((match-group-of-attribute-value (if (match-beginning 2) 2 3))
- (attribute-value-face
- (adoc-face-for-attribute pos-or-name-of-attribute
prop-of-attribute-list)))
- (put-text-property
- (match-beginning match-group-of-attribute-value)
- (match-end match-group-of-attribute-value)
- 'face attribute-value-face))
-
- (when (numberp pos-or-name-of-attribute)
- (setq pos-or-name-of-attribute (1+ pos-or-name-of-attribute))))
+ (point) attribute-list-end
+ 'face markup-secondary-text-face)
+
+ ;; for each attribute in current attribute list
+ (while (re-search-forward (adoc-re-attribute-list-elt)
attribute-list-end t)
+ (when (match-beginning 1); i.e. when it'a named attribute
+ ;; get attribute's name
+ (setq pos-or-name-of-attribute
+ (buffer-substring-no-properties (match-beginning 1)
(match-end 1)))
+ ;; fontify the attribute's name with markup-attribute-face
+ (put-text-property
+ (match-beginning 1) (match-end 1) 'face markup-attribute-face))
+
+ ;; fontify the attribute's value
+ (let ((match-group-of-attribute-value (if (match-beginning 2) 2 3))
+ (attribute-value-face
+ (adoc-face-for-attribute pos-or-name-of-attribute
prop-of-attribute-list)))
+ (put-text-property
+ (match-beginning match-group-of-attribute-value)
+ (match-end match-group-of-attribute-value)
+ 'face attribute-value-face))
+
+ (when (numberp pos-or-name-of-attribute)
+ (setq pos-or-name-of-attribute (1+ pos-or-name-of-attribute)))))
(goto-char attribute-list-end))))
nil)
@@ -1496,17 +1503,19 @@ When LITERAL-P is non-nil, the contained text is
literal text."
'(3 nil)) ; grumbl, I dont know how to get rid of it
`(4 '(face ,(or del-face markup-meta-hide-face) adoc-reserved t) t)));
close del
-(defun adoc-kw-inline-macro (&optional cmd-name cmd-face target-faces
target-meta-p attribute-list)
+(defun adoc-kw-inline-macro (&optional cmd-name unconstrained cmd-face
target-faces target-meta-p attribute-list)
"Returns a kewyword which highlights an inline macro.
-For CMD-NAME see `adoc-re-inline-macro'. CMD-FACE determines face
-for the command text. If nil, `markup-command-face' is used.
-TARGET-FACES determines face for the target text. If nil
-`markup-meta-face' is used. If a list, the first is used if the
-attribute list is the empty string, the second is used if its not
-the empty string. If TARGET-META-P is non-nil, the target text is
-considered to be meta characters."
+
+For CMD-NAME and UNCONSTRAINED see
+`adoc-re-inline-macro'. CMD-FACE determines face for the command
+text. If nil, `markup-command-face' is used. TARGET-FACES
+determines face for the target text. If nil `markup-meta-face' is
+used. If a list, the first is used if the attribute list is the
+empty string, the second is used if its not the empty string. If
+TARGET-META-P is non-nil, the target text is considered to be
+meta characters."
(list
- `(lambda (end) (adoc-kwf-std end ,(adoc-re-inline-macro cmd-name) '(1 2 4
5) '(0)))
+ `(lambda (end) (adoc-kwf-std end ,(adoc-re-inline-macro cmd-name nil
unconstrained) '(1 2 4 5) '(0)))
`(1 '(face ,(or cmd-face markup-command-face) adoc-reserved t) t) ; cmd-name
'(2 '(face markup-meta-face adoc-reserved t) t) ; :
`(3 ,(cond ((not target-faces) markup-meta-face) ; target
@@ -2009,16 +2018,12 @@ considered to be meta characters."
;; Macros using default syntax, but having special highlighting in adoc-mode
(adoc-kw-inline-macro-urls-no-attribute-list)
(adoc-kw-inline-macro-urls-attribute-list)
- (adoc-kw-inline-macro "anchor" nil markup-anchor-face t '("xreflabel"))
- (adoc-kw-inline-macro "image" markup-complex-replacement-face
markup-internal-reference-face t
+ (adoc-kw-inline-macro "anchor" nil nil markup-anchor-face t '("xreflabel"))
+ (adoc-kw-inline-macro "image" nil markup-complex-replacement-face
markup-internal-reference-face t
'("alt"))
- (adoc-kw-inline-macro "xref" nil '(markup-reference-face
markup-internal-reference-face) t
+ (adoc-kw-inline-macro "xref" nil nil '(markup-reference-face
markup-internal-reference-face) t
'(("caption") (("caption" . markup-reference-face))))
- (list "\\(\\bfootnote:\\)\\(\\[\\)\\(.*?\\(?:\n.*?\\)?\\)\\(\\]\\)"
- '(1 adoc-delimiter) ; name
- '(2 adoc-hide-delimiter) ; [
- '(3 adoc-secondary-text) ; footnote text
- '(4 adoc-hide-delimiter)) ; ]
+ (adoc-kw-inline-macro "footnote" t nil nil nil 'entire-attribute-list)
(list
"\\(\\bfootnoteref:\\)\\(\\[\\)\\(.*?\\)\\(,\\)\\(.*?\\(?:\n.*?\\)?\\)\\(\\]\\)"
'(1 adoc-delimiter) ; name
'(2 adoc-hide-delimiter) ; [
- [nongnu] elpa/adoc-mode cacd4e8f67 127/199: Correct links. Avoid some warnings for adoc-mode-test.el, (continued)
- [nongnu] elpa/adoc-mode cacd4e8f67 127/199: Correct links. Avoid some warnings for adoc-mode-test.el, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 3226a938a6 131/199: Update the custom group, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 4508af7824 141/199: Bump the development version, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode b204c4bbef 140/199: Fix license badge, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 8d42a05372 142/199: Move tests to a dedicated folder, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 753406593a 146/199: Tweak a heading, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode b992b3bfc8 147/199: Shorten the README's extension, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode fb1e49d7e1 153/199: Use setq-local where appropriate, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 800c316c90 155/199: [Fix #16] Prevent forward references error in adoc-mode-map, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode d3517e596d 102/199: all special inline macros are now fontified before the general inline macro, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode e36c0105ab 104/199: improved fontifying for footnotes,
ELPA Syncer <=
- [nongnu] elpa/adoc-mode 21bb167f67 108/199: improved comments and whites, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 8f8a1ef307 111/199: bumped version to 0.6.5, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode c117d58b4b 119/199: Merge pull request #1 from lukesanantonio/master, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 7ec9c3569d 134/199: Make TODO notes stand out, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 296df94325 135/199: Fix a bunch of typos, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 99917e0bdd 069/199: adoc-re-inline-macro can now be told to match only an empty attribute list, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode a976f1ac84 085/199: edited commentary section, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 7aa44fea5b 089/199: in menu, unicode chars for (R) and (TM) were interchanged, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 0ea3de138a 091/199: refactored adoc-kwf-attriblist, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 9bea822e07 136/199: Add license badge, ELPA Syncer, 2023/09/03