branch: elpa/adoc-mode
commit fbad6f0071d93c34ea06526c120ec3a9177e08a6
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>
Recognise modern curved-quote syntax
"`text`" (double) and '`text`' (single) produce curved quotation
marks in modern AsciiDoc. Register them as constrained quotes with
asymmetric delimiters ahead of the backtick keywords, so the enclosing
backticks form the quote delimiter instead of being mis-read as inline
monospace; the enclosed text stays in the default face.
---
CHANGELOG.md | 1 +
adoc-mode.el | 7 +++++++
doc/spec-compliance.adoc | 12 +++++++-----
test/adoc-mode-test.el | 14 ++++++++++++++
4 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 907ece68fe..6f5a5d61c3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
### New features
+- Recognise the modern curved-quote syntax `"`text`"` (double) and `'`text`'`
(single). The delimiters are de-emphasised and the enclosed text is shown as
normal text; previously the inner backticks were mis-highlighted as inline
monospace.
- Recognise the `icon:target[attrlist]` inline macro (e.g. `icon:heart[2x]`),
highlighting the macro name, the icon name/path, and its attribute list like
the other inline macros.
- Recognise the modern block ID shorthand `[#id]`. The id in a `[#id]` /
`[#id.role%opt]` block-attribute line is now highlighted like an anchor
(`adoc-anchor-face`), and cross-reference following (`adoc-goto-ref-label`,
`M-.`) jumps to `[#id]` block IDs - including the `[style#id]` form, e.g.
`[source#id]` - not just `[[id]]` anchors.
- Highlight checklist items. An unordered list item whose text begins with `[
]` (unchecked), `[x]`/`[X]`, or `[*]` (checked) now fontifies the checkbox with
the new `adoc-checkbox-face` (inherits `font-lock-constant-face`).
diff --git a/adoc-mode.el b/adoc-mode.el
index 9a0251273a..c3c5d4f51d 100644
--- a/adoc-mode.el
+++ b/adoc-mode.el
@@ -2652,6 +2652,13 @@ for multiline constructs to be matched."
;; below so the escaped delimiters are reserved before they are scanned)
(adoc-kw-escaped-formatting)
+ ;; Curved (smart) quotes: "`text`" -> double, '`text`' -> single. These
+ ;; must precede the backtick keywords below so the enclosing backticks are
+ ;; taken as part of the quote delimiter rather than as inline code. The
+ ;; enclosed text is normal text, so it gets no special face.
+ (adoc-kw-quote 'adoc-constrained "\"`" nil nil "`\"")
+ (adoc-kw-quote 'adoc-constrained "'`" nil nil "`'")
+
;; Inline code and passthroughs
;; ----------------------------
;; Asciidoctor: `text` is inline code (monospace literal)
diff --git a/doc/spec-compliance.adoc b/doc/spec-compliance.adoc
index 36924e4dcb..3539e096a9 100644
--- a/doc/spec-compliance.adoc
+++ b/doc/spec-compliance.adoc
@@ -44,8 +44,9 @@ Findings are graded:
| High
| text
-| Modern curved-quote syntax `+"`text`"+` (double) and ``'`text`'`` (single)
- is not recognised.
+| [.line-through]#Modern curved-quote syntax `+"`text`"+` / ``'`text`'`` is
+ not recognised.# *FIXED* - recognised; delimiters de-emphasised, enclosed
+ text normal (and the inner backticks are no longer mis-read as monospace).
| Medium
| text
@@ -116,8 +117,8 @@ Findings are graded:
| Curved quotes `+"`x`"+` / ``'`x`'``
| Modern smart-quote syntax (backticks inside straight quotes)
-| Not recognised
-| Medium
+| *Fixed* - delimiters de-emphasised, enclosed text normal
+| -
| Legacy curved quotes `` `x' `` / ``\`\`x''``
| Deprecated in Asciidoctor
@@ -385,7 +386,8 @@ implements.
(`block-id-shorthand`) and `adoc-goto-ref-label` follows `[#id]` (and
`[style#id]`) targets. Faceting `.role` / `%opt` inside arbitrary
attribute lists is left as a smaller follow-up.
-. [ ] *Add modern curved-quote highlighting* `+"`text`"+` and ``'`text`'``.
+. [x] *Add modern curved-quote highlighting* `+"`text`"+` and ``'`text`'``.
+ Done.
. [ ] *Drop or de-emphasise the deprecated `` `text' `` / ``\`\`text''``
templates* in the menu (and the `+...+` / `++...++` "Monospaced"
templates), or relabel them as legacy.
diff --git a/test/adoc-mode-test.el b/test/adoc-mode-test.el
index 818d9d6a5f..4a7a858571 100644
--- a/test/adoc-mode-test.el
+++ b/test/adoc-mode-test.el
@@ -1179,6 +1179,20 @@ on top of the `<mark>' default)."
(should (memq 'adoc-typewriter-face
(if (listp faces) faces (list faces)))))))
+;;;; Curved (smart) quotes
+
+(ert-deftest adoctest-test-curved-quotes ()
+ ;; "`text`" / '`text`' : delimiters de-emphasised, enclosed text normal
+ ;; (and crucially the inner backticks are not taken as inline code)
+ (adoctest-faces "curved-double"
+ "\"`" 'adoc-meta-hide-face "hello" 'no-face "`\""
'adoc-meta-hide-face)
+ (adoctest-faces "curved-single"
+ "'`" 'adoc-meta-hide-face "great" 'no-face "`'"
'adoc-meta-hide-face))
+
+(ert-deftest adoctest-test-plain-double-quotes-untouched ()
+ ;; ordinary straight quotes (no backticks) are not markup
+ (adoctest-faces "plain-quotes" "say \"text\" here" 'no-face))
+
;;;; Filling
(ert-deftest adoctest-test-fill-preserves-hard-break ()