branch: elpa/adoc-mode commit a0ddf0f02d417fc4d5d32b1480420d03ee9e6429 Author: Florian Kaufmann <sensor...@gmail.com> Commit: Florian Kaufmann <sensor...@gmail.com>
added tests for images --- adoc-mode-test.el | 42 ++++++++++++++++++++++++++++++++++++++++-- adoc-mode.el | 12 ++++++------ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/adoc-mode-test.el b/adoc-mode-test.el index b3f045881a..c6f7678f35 100644 --- a/adoc-mode-test.el +++ b/adoc-mode-test.el @@ -1,4 +1,3 @@ - (require 'ert) (require 'adoc-mode) @@ -135,6 +134,45 @@ ;; tested in delimited-blocks-simple )) +(ert-deftest adoctest-test-images () + (adoctest-faces "images" + ;; block macros + ;; empty arglist + "image" markup-complex-replacement-face "::" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[]" markup-meta-face "\n" nil + ;; pos attribute 0 = alternate text + "image" markup-complex-replacement-face "::" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "\n" nil + ;; keyword title + "image" markup-complex-replacement-face "::" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "\n" nil + ;; keyword alt and title + "image" markup-complex-replacement-face "::" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "," markup-meta-face + "title" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "\n" nil + + ;; no everything again with inline macros + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[]" markup-meta-face "bar" 'no-face "\n" nil + + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "bar" 'no-face "\n" nil + + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "bar" 'no-face "\n" nil + + "foo " 'no-face "image" markup-complex-replacement-face ":" markup-meta-face + "./foo/bar.png" markup-internal-reference-face + "[" markup-meta-face "alt" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "," markup-meta-face + "title" markup-attribute-face "=" markup-meta-face "lorem ipsum" markup-secondary-text-face "]" markup-meta-face "bar" 'no-face "\n" nil)) + (ert-deftest adoctest-test-attribute-list () (adoctest-faces "attribute-list" ;; positional attribute @@ -372,5 +410,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 42a8fe5887..7e7d8640b2 100644 --- a/adoc-mode.el +++ b/adoc-mode.el @@ -721,7 +721,7 @@ Subgroups: 2 target 3 attribute list, exclusive brackets []" ;; !!! \< is not exactly what AsciiDoc does, see regex above - (concat "\\<\\(" cmd-name "\\):\\([^ \t\n].*\\)[\\(.*?\\)]" )) + (concat "\\<\\(" cmd-name "\\):\\([^ \t\n].*\\)\\[\\(.*?\\)\\]" )) ;; todo: use same regexps as for font lock (defun adoc-re-paragraph-separate () @@ -1009,10 +1009,10 @@ When LITERAL-P is non-nil, the contained text is literal text." '(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 + '(3 '(face markup-meta-face adoc-reserved nil adoc-attribute-list (((0 "alt") markup-secondary-text-face) - ("title" markup-secondary-text-face)))))) + ("title" markup-secondary-text-face))) t))) ;; bug: escapes are not handled yet ;; todo: give the inserted character a specific face. But I fear that is not @@ -1198,10 +1198,10 @@ When LITERAL-P is non-nil, the contained text is literal text." ;; image ;; (?u)^(?P<name>image|unfloat)::(?P<target>\S*?)(\[(?P<attrlist>.*?)\])$ (list "^\\(image\\)::\\([^ \t\n]*?\\)\\[\\(.*?\\)\\][ \t]*$" - '(0 '(face markup-delimiter-face adoc-reserved block-del)) ; whole match + '(0 '(face markup-meta-face adoc-reserved block-del)) ; whole match '(1 markup-complex-replacement-face t) ; macro name '(2 markup-internal-reference-face t) ; file name - '(3 '(face markup-delimiter-face + '(3 '(face markup-meta-face adoc-reserved nil adoc-attribute-list (((0 "alt") markup-secondary-text-face) ("title" markup-secondary-text-face))) @@ -1325,7 +1325,7 @@ When LITERAL-P is non-nil, the contained text is literal text." ;; ^\[(?P<attrlist>.*)\]$ (list "^\\(\\[\\(.*\\)\\]\\)[ \t]*$" '(1 '(face markup-meta-face adoc-reserved block-del)) - '(2 '(face markup-delimiter-face adoc-attribute-list t))) + '(2 '(face markup-meta-face adoc-attribute-list t))) ;; block title