Function: org-element-export-block-parser

org-element-export-block-parser is a byte-compiled function defined in org-element.el.gz.

Signature

(org-element-export-block-parser LIMIT AFFILIATED)

Documentation

Parse an export block.

LIMIT bounds the search. AFFILIATED is a list of which CAR is the buffer position at the beginning of the first affiliated keyword and CDR is a plist of affiliated keywords along with their value.

Return a new syntax node of export-block type containing :begin,
:end, :type, :value, :post-blank and :post-affiliated
properties.

Assume point is at export-block beginning.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
;;;; Export Block

(defun org-element-export-block-parser (limit affiliated)
  "Parse an export block.

LIMIT bounds the search.  AFFILIATED is a list of which CAR is
the buffer position at the beginning of the first affiliated
keyword and CDR is a plist of affiliated keywords along with
their value.

Return a new syntax node of `export-block' type containing `:begin',
`:end', `:type', `:value', `:post-blank' and `:post-affiliated'
properties.

Assume point is at export-block beginning."
  (let* ((case-fold-search t))
    (if (not (save-excursion
	       (re-search-forward "^[ \t]*#\\+END_EXPORT[ \t]*$" limit t)))
	;; Incomplete block: parse it as a paragraph.
	(org-element-paragraph-parser limit affiliated)
      (save-excursion
	(let* ((contents-end (match-beginning 0))
	       (backend
		(progn
		  (looking-at
		   "[ \t]*#\\+BEGIN_EXPORT\\(?:[ \t]+\\(\\S-+\\)\\)?[ \t]*$")
		  (match-string-no-properties 1)))
	       (begin (car affiliated))
	       (post-affiliated (point))
	       (contents-begin (progn (forward-line) (point)))
	       (pos-before-blank (progn (goto-char contents-end)
					(forward-line)
					(point)))
	       (end (progn (skip-chars-forward " \r\t\n" limit)
			   (if (eobp) (point) (line-beginning-position))))
	       (value
                (org-element-deferred-create
                 t #'org-element--unescape-substring
                 (- contents-begin begin)
                 (- contents-end begin))))
	  (org-element-create
           'export-block
	   (nconc
	    (list :type (and backend (upcase backend))
		  :begin begin
		  :end end
		  :value value
		  :post-blank (count-lines pos-before-blank end)
		  :post-affiliated post-affiliated)
	    (cdr affiliated))))))))