branch: elpa/adoc-mode
commit ab42f4909a769f3c021813b2970322d7869f54dd
Author: sensorflo <[email protected]>
Commit: sensorflo <[email protected]>
(un)constrained quotes can now spawn more than two lines
---
adoc-mode-test.el | 16 +++++++++++-----
adoc-mode.el | 26 ++++++++++++++++++++++++--
2 files changed, 35 insertions(+), 7 deletions(-)
diff --git a/adoc-mode-test.el b/adoc-mode-test.el
index 836a5eeeae..7eb6371754 100644
--- a/adoc-mode-test.el
+++ b/adoc-mode-test.el
@@ -449,11 +449,17 @@ removed before TRANSFORM is evaluated.
(ert-deftest adoctest-test-quotes-medium ()
(adoctest-faces "test-quotes-medium"
;; test wheter constrained/unconstrained quotes can spawn multiple lines
- "Lorem " 'no-face "*" markup-meta-hide-face "ipsum" markup-strong-face "\n"
nil
- "dolor" markup-strong-face "*" markup-meta-hide-face " sit" 'no-face "\n"
nil
- "Lorem " 'no-face "__" markup-meta-hide-face "ipsum" markup-emphasis-face
"\n" nil
- "dolor" markup-emphasis-face "__" markup-meta-hide-face " sit" 'no-face
"\n" nil
- "\n" nil
+ "Lorem " 'no-face "*" markup-meta-hide-face "ipsum" markup-strong-face
+ "\n" nil "dolor" markup-strong-face "\n" nil "dolor" markup-strong-face
+ "\n" nil "dolor" markup-strong-face "\n" nil "dolor" markup-strong-face
+ "*" markup-meta-hide-face
+ " sit" 'no-face "\n" nil
+
+ "Lorem " 'no-face "__" markup-meta-hide-face "ipsum" markup-emphasis-face
+ "\n" nil "dolor" markup-emphasis-face "\n" nil "dolor" markup-emphasis-face
+ "\n" nil "dolor" markup-emphasis-face "\n" nil "dolor" markup-emphasis-face
+ "__" markup-meta-hide-face
+ " sit" 'no-face "\n" nil
;; tests border case that delimiter is at the beginnin/end of an
paragraph/line
;; constrained at beginning
diff --git a/adoc-mode.el b/adoc-mode.el
index 36b140157b..0ec9216885 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -1122,7 +1122,7 @@ NOT-ALLOWED-CHARS are chars not allowed before the quote."
(adoc-re-quote-precondition "")
"\\(\\[[^][]+?\\]\\)?"
"\\(" qldel "\\)"
- "\\(.+?\\(?:\n.*?\\)\\{,1\\}?\\)"
+ "\\(" (adoc-re-content "+") "\\)"
"\\(" qrdel "\\)")))
;; AsciiDoc src for constrained quotes
@@ -1149,7 +1149,7 @@ subgroups:
(adoc-re-quote-precondition "A-Za-z0-9;:}&<>")
"\\(\\[[^][]+?\\]\\)?"
"\\(" qldel "\\)"
- "\\([^ \t\n]\\|[^ \t\n].*?\\(?:\n.*?\\)\\{,1\\}?[^ \t\n]\\)"
+ "\\([^ \t\n]\\|[^ \t\n]" (adoc-re-content) "[^ \t\n]\\)"
"\\(" qrdel "\\)"
;; BUG: now that Emacs doesn't has look-ahead, the match is too long, and
;; adjancted quotes of the same type wouldn't be recognized.
@@ -1273,6 +1273,28 @@ Subgroups of returned regexp:
(style "[demshalv]"))
(concat "\\(?:" fullspan "\\)?\\(?:" align "\\)?\\(?:" style "\\)?")))
+;; bug: if qualifier is "+", and the thing to match starts at the end of a
+;; line (i.e. the first char is newline), then wrongly this regexp does
+;; never match.
+;; Note: asciidoc uses Python's \s to determine blank lines, while _not_
+;; setting either the LOCALE or UNICODE flag, see
+;; Reader.skip_blank_lines. Python uses [ \t\n\r\f\v] for it's \s . So
+;; the horizontal spaces are [ \t].
+(defun adoc-re-content (&optional qualifier)
+ "Matches content, possibly spawning multiple non-blank lines"
+ (concat
+ "\\(?:"
+ ;; content on initial line
+ "." (or qualifier "*") "?"
+ ;; if content spawns multiple lines
+ "\\(?:\n"
+ ;; complete non blank lines
+ "\\(?:[ \t]*\\S-.*\n\\)*?"
+ ;; leading content on last line
+ ".*?"
+ "\\)??"
+ "\\)"))
+
;;;; font lock keywords
(defun adoc-kwf-std (end regexp &optional must-free-groups no-block-del-groups)