[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/adoc-mode 105519ce37 033/199: changed image fontification
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/adoc-mode 105519ce37 033/199: changed image fontification without tests, added tests for attribute lists |
Date: |
Sun, 3 Sep 2023 06:59:25 -0400 (EDT) |
branch: elpa/adoc-mode
commit 105519ce3773795fa40cbb635ee3935526da8027
Author: Florian Kaufmann <sensorflo@gmail.com>
Commit: Florian Kaufmann <sensorflo@gmail.com>
changed image fontification without tests, added tests for attribute lists
---
adoc-mode-test.el | 40 +++++++++++++++++++++++++++-------------
adoc-mode.el | 55 ++++++++++++++++++++++++++++++++-----------------------
2 files changed, 59 insertions(+), 36 deletions(-)
diff --git a/adoc-mode-test.el b/adoc-mode-test.el
index 3e3fe96808..b3f045881a 100644
--- a/adoc-mode-test.el
+++ b/adoc-mode-test.el
@@ -135,18 +135,32 @@
;; tested in delimited-blocks-simple
))
-(ert-deftest adoctest-test- ()
- (adoctest-faces "comments"
- ;; as block macro
- "// lorem ipsum\n" markup-comment-face
- "\n" nil
- ;; as inline macro
- "lorem ipsum\n" 'no-face
- "// dolor sit\n" markup-comment-face
- "amen\n" 'no-face
- "\n" nil
- ;; as delimited block
- ;; tested in delimited-blocks-simple
+(ert-deftest adoctest-test-attribute-list ()
+ (adoctest-faces "attribute-list"
+ ;; positional attribute
+ "[" markup-meta-face "hello" markup-value-face "]" markup-meta-face "\n"
nil
+ ;; positional attribute containing spaces
+ "[" markup-meta-face "hello world" markup-value-face "]" markup-meta-face
"\n" nil
+ ;; positional attribute as string
+ "[\"" markup-meta-face "hello world" markup-value-face "\"]"
markup-meta-face "\n" nil
+
+ ;; multiple positional attributes
+ "[" markup-meta-face "hello" markup-value-face "," markup-meta-face
"world" markup-value-face "]" markup-meta-face "\n" nil
+
+ ;; keyword attribute
+ "[" markup-meta-face "salute" markup-attribute-face "=" markup-meta-face
"hello" markup-value-face "]" markup-meta-face "\n" nil
+ ;; keyword attribute where value is a string
+ "[" markup-meta-face "salute" markup-attribute-face "=\"" markup-meta-face
"hello world" markup-value-face "\"]" markup-meta-face "\n" nil
+
+ ;; multiple positional attributes, multiple keyword attributes
+ "[" markup-meta-face "lorem" markup-value-face "," markup-meta-face
"ipsum" markup-value-face "," markup-meta-face
+ "dolor" markup-attribute-face "=" markup-meta-face "sit"
markup-value-face "," markup-meta-face
+ "dolor" markup-attribute-face "=" markup-meta-face "sit"
markup-value-face "]" markup-meta-face "\n" nil
+
+ ;; is , within strings really part of the string and not mistaken as
element separator
+ "[\"" markup-meta-face "lorem,ipsum=dolor" markup-value-face "\"]"
markup-meta-face "\n" nil
+ ;; does escaping " in strings work
+ "[\"" markup-meta-face "lorem \\\"ipsum\\\" dolor" markup-value-face "\"]"
markup-meta-face "\n" nil
))
(ert-deftest adoctest-test-quotes-simple ()
@@ -358,5 +372,5 @@
(save-buffer "adoc-mode.el")
(save-buffer "adoc-mode-test.el")
(ert-run-tests-interactively "^adoctest-pre-test-byte-compile")
- (ert-run-tests-interactively "^adoctest-test-"))
+ (ert-run-tests-interactively "^adoctest-test"))
diff --git a/adoc-mode.el b/adoc-mode.el
index e89fb5a0c8..42a8fe5887 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -617,7 +617,7 @@ Subgroups:
"\\(?:"
;; regexp for string: See 'Mastering Regular Expressions', chapter 'The
;; Real "Unrolling-the-Loop" Pattern'.
- "\"\\([^\"]*\\(?:\\.[^\"]*\\)*\\)\"[ \t\n]*" "\\|" ; 2
+ "\"\\([^\"\\]*\\(?:\\\\.[^\"\\]*\\)*\\)\"[ \t\n]*" "\\|" ; 2
"\\([^,]+\\)" ; 3
"\\)"))
@@ -710,6 +710,19 @@ subgroups:
(t
(error "Invalid type"))))
+;; Macros using default syntax.
+;;
(?<!\w)[\\]?(?P<name>http|https|ftp|file|irc|mailto|callto|image|link|anchor|xref|indexterm):(?P<target>\S*?)\[(?P<attrlist>.*?)\]
+;; Default (catchall) inline macro is not implemented
+;; # [\\]?(?P<name>\w(\w|-)*?):(?P<target>\S*?)\[(?P<passtext>.*?)(?<!\\)\]
+(defun adoc-re-inline-macro (cmd-name)
+ "Returns regex matching an inline macro.
+Subgroups:
+1 cmd name
+2 target
+3 attribute list, exclusive brackets []"
+ ;; !!! \< is not exactly what AsciiDoc does, see regex above
+ (concat "\\<\\(" cmd-name "\\):\\([^ \t\n].*\\)[\\(.*?\\)]" ))
+
;; todo: use same regexps as for font lock
(defun adoc-re-paragraph-separate ()
(concat
@@ -988,6 +1001,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-image ()
+ (list
+ ;; matcher function
+ `(lambda (end) (adoc-kwf-std end ,(adoc-re-inline-macro "image") '(1 2)
'(0)))
+ ;; highlighers
+ '(0 '(face markup-meta-face adoc-reserved t) t)
+ '(1 markup-complex-replacement-face t)
+ '(2 markup-internal-reference-face t)
+ '(3 '(face markup-delimiter-face
+ adoc-reserved nil
+ adoc-attribute-list (((0 "alt") markup-secondary-text-face)
+ ("title" markup-secondary-text-face))))))
+
;; bug: escapes are not handled yet
;; todo: give the inserted character a specific face. But I fear that is not
;; possible. The string inserted with the ovlerlay property after-string gets
@@ -1176,6 +1202,7 @@ When LITERAL-P is non-nil, the contained text is literal
text."
'(1 markup-complex-replacement-face t) ; macro name
'(2 markup-internal-reference-face t) ; file name
'(3 '(face markup-delimiter-face
+ adoc-reserved nil
adoc-attribute-list (((0 "alt") markup-secondary-text-face)
("title" markup-secondary-text-face)))
t)) ; attribute list
@@ -1297,8 +1324,8 @@ When LITERAL-P is non-nil, the contained text is literal
text."
;; --- general attribute list
;; ^\[(?P<attrlist>.*)\]$
(list "^\\(\\[\\(.*\\)\\]\\)[ \t]*$"
- '(1 '(face adoc-delimiter adoc-reserved block-del))
- '(2 '(face markup-delimiter-face 'adoc-attribute-list t)))
+ '(1 '(face markup-meta-face adoc-reserved block-del))
+ '(2 '(face markup-delimiter-face adoc-attribute-list t)))
;; block title
@@ -1432,26 +1459,8 @@ When LITERAL-P is non-nil, the contained text is literal
text."
(list "\\b\\(xref:\\)\\([^ \t\n]*?\\)\\(\\[\\)\\(.*?\\)\\(,.*?\\)?\\(\\]\\)"
'(1 adoc-hide-delimiter) '(2 adoc-delimiter) '(3 adoc-hide-delimiter)
'(4 adoc-reference) '(5 adoc-delimiter nil t) '(6 adoc-hide-delimiter))
- ;; todo: fontify alt and title attribute value
- ;; todo: one regexp for both inline/block image macro
- ;; 1 2 3 4 5 6
7 8 9
- (list "\\b\\(image:\\)\\(:?\\)\\([^
\t\n]*?\\)\\(\\[\\(\"?\\)\\)\\([^=\n]*?\\)\\(\\5[ \t]*,\\)\\(.*?\\)?\\(\\]\\)"
- '(1 adoc-hide-delimiter) ; macro name
- '(2 adoc-warning) ; if there are two colons, we have a
bogous block macro
- '(3 adoc-complex-replacement) ; file name
- '(4 adoc-hide-delimiter) ; ["
- '(6 adoc-secondary-text) ; first positional argument is
caption
- '(7 adoc-hide-delimiter) ; ",
- '(8 adoc-delimiter nil t) ; rest of attribute list
- '(9 adoc-hide-delimiter)) ; ]
- (list "\\b\\(image:\\)\\(:?\\)\\([^ \t\n]*?\\)\\(\\[\\)\\(.*?\\)\\(\\]\\)"
- '(1 adoc-hide-delimiter) ; macro name
- '(2 adoc-warning) ; if there are two colons, we have a
bogous block macro
- '(3 adoc-complex-replacement) ; file name
- '(4 adoc-hide-delimiter) ; [
- '(5 adoc-delimiter) ; attribute list content
- '(6 adoc-hide-delimiter)) ; ]
-
+ (adoc-kw-inline-image)
+
(list "\\(anchor:\\)\\([^ \t\n]*?\\)\\(\\[\\)\\(.*?\\)\\(,.*?\\)?\\(\]\\)"
'(1 adoc-hide-delimiter) '(2 adoc-anchor) '(3 adoc-hide-delimiter)
'(4 adoc-secondary-text) '(5 adoc-delimiter nil t) '(6 adoc-hide-delimiter))
;; standalone email, SIMPLE reglex! copied from
http://www.regular-expressions.info/email.html
- [nongnu] elpa/adoc-mode 06f9792fcd 011/199: added further simple tests for constrained/uncronstrained quotes, (continued)
- [nongnu] elpa/adoc-mode 06f9792fcd 011/199: added further simple tests for constrained/uncronstrained quotes, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode ead05da007 014/199: split up the current big test into smaller ones, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode f519baf304 022/199: addef *.elc files to .gitignore, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 886497d6a6 023/199: added a few medium complex tests for (un)constrained quotes, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode b65c7fcb92 026/199: block title now fits into the new concept, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 0f7619cfce 027/199: enheanced inline-subst-boundaries test, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode b8e8574afa 038/199: introduced adoc-attribute-face-alist, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode e03d63e0b3 039/199: extened anchors unittest and fixed revealed bug, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 6ccb9d6de5 009/199: intermediate checkin - to be removed, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode ce247928ec 021/199: added test for byte-compile-file without errors, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 105519ce37 033/199: changed image fontification without tests, added tests for attribute lists,
ELPA Syncer <=
- [nongnu] elpa/adoc-mode 3d2ab81750 041/199: new style font lock for xref inline macro, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 9c404a4e2d 042/199: test2, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 2756c62d86 043/199: revert test2, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode d4a57c5c03 045/199: cleaned up file comments a bit, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 97602c1577 046/199: fixed important typo, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 7b0009904e 047/199: updated URL and copyright date, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode a08c7f26cc 053/199: bugfixes for promote / denote title, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 504d490785 055/199: test: running the test is now more smoothly, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode fb170735f8 056/199: bugfixes and new tests for promote/denote/toggle title, ELPA Syncer, 2023/09/03
- [nongnu] elpa/adoc-mode 4e13247892 058/199: test: added test for adjust-title-del, ELPA Syncer, 2023/09/03