Function: org-element-macro-parser
org-element-macro-parser is a byte-compiled function defined in
org-element.el.gz.
Signature
(org-element-macro-parser)
Documentation
Parse macro at point, if any.
When at a macro, return a new syntax node of macro type containing
:key, :args, :begin, :end, :value and :post-blank as
properties. Otherwise, return nil.
Assume point is at the macro.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
;;;; Macro
(defun org-element-macro-parser ()
"Parse macro at point, if any.
When at a macro, return a new syntax node of `macro' type containing
`:key', `:args', `:begin', `:end', `:value' and `:post-blank' as
properties. Otherwise, return nil.
Assume point is at the macro."
(save-excursion
(when (looking-at "{{{\\([a-zA-Z][-a-zA-Z0-9_]*\\)\\((\\(\\(?:.\\|\n\\)*?\\))\\)?}}}")
(let ((begin (point))
(key (org-element--get-cached-string
(downcase (match-string-no-properties 1))))
(value (match-string-no-properties 0))
(post-blank (progn (goto-char (match-end 0))
(skip-chars-forward " \t")))
(end (point))
(args (pcase (match-string-no-properties 3)
(`nil nil)
(a (org-macro-extract-arguments
(replace-regexp-in-string
"[ \t\r\n]+" " " (org-trim a)))))))
(org-element-create
'macro
(list :key key
:value value
:args args
:begin begin
:end end
:post-blank post-blank))))))