org-element: Ignore contiguous spaces in macro arguments
* lisp/org-element.el (org-element-macro-parser): Ignore non-meaningful spaces (e.g., indentation). (org-element-macro-interpreter): Do not interpret macro from its raw value. Instead, build it again from its parsed contents.
This commit is contained in:
parent
55e8c6f9c3
commit
04bf418922
|
@ -3247,15 +3247,18 @@ a plist with `:key', `:args', `:begin', `:end', `:value' and
|
||||||
|
|
||||||
Assume point is at the macro."
|
Assume point is at the macro."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\(([ \t\n]*\\([^\000]*?\\))\\)?}}}")
|
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\([^\000]*?\\))\\)?}}}")
|
||||||
(let ((begin (point))
|
(let ((begin (point))
|
||||||
(key (downcase (match-string-no-properties 1)))
|
(key (downcase (match-string-no-properties 1)))
|
||||||
(value (match-string-no-properties 0))
|
(value (match-string-no-properties 0))
|
||||||
(post-blank (progn (goto-char (match-end 0))
|
(post-blank (progn (goto-char (match-end 0))
|
||||||
(skip-chars-forward " \t")))
|
(skip-chars-forward " \t")))
|
||||||
(end (point))
|
(end (point))
|
||||||
(args (let ((args (match-string-no-properties 3)))
|
(args (pcase (match-string-no-properties 3)
|
||||||
(and args (org-macro-extract-arguments args)))))
|
(`nil nil)
|
||||||
|
(a (org-macro-extract-arguments
|
||||||
|
(replace-regexp-in-string
|
||||||
|
"[ \t\r\n]+" " " (org-trim a)))))))
|
||||||
(list 'macro
|
(list 'macro
|
||||||
(list :key key
|
(list :key key
|
||||||
:value value
|
:value value
|
||||||
|
@ -3266,7 +3269,11 @@ Assume point is at the macro."
|
||||||
|
|
||||||
(defun org-element-macro-interpreter (macro _)
|
(defun org-element-macro-interpreter (macro _)
|
||||||
"Interpret MACRO object as Org syntax."
|
"Interpret MACRO object as Org syntax."
|
||||||
(org-element-property :value macro))
|
(format "{{{%s%s}}}"
|
||||||
|
(org-element-property :key macro)
|
||||||
|
(pcase (org-element-property :args macro)
|
||||||
|
(`nil "")
|
||||||
|
(args (format "(%s)" (apply #'org-macro-escape-arguments args))))))
|
||||||
|
|
||||||
|
|
||||||
;;;; Radio-target
|
;;;; Radio-target
|
||||||
|
|
Loading…
Reference in New Issue