Function: org-element-table-parser

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

Signature

(org-element-table-parser LIMIT AFFILIATED)

Documentation

Parse a table at point.

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 table type containing :begin, :end,
:tblfm, :type, :contents-begin, :contents-end, :value,
:post-blank and :post-affiliated properties.

Assume point is at the beginning of the table.

Source Code

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

(defun org-element-table-parser (limit affiliated)
  "Parse a table at point.

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 `table' type containing `:begin', `:end',
`:tblfm', `:type', `:contents-begin', `:contents-end', `:value',
`:post-blank' and `:post-affiliated' properties.

Assume point is at the beginning of the table."
  (save-excursion
    (let* ((case-fold-search t)
	   (table-begin (point))
	   (type (if (looking-at-p "[ \t]*|") 'org 'table.el))
           (end-re (format "^[ \t]*\\($\\|[^| \t%s]\\)"
			   (if (eq type 'org) "" "+")))
	   (begin (car affiliated))
	   (table-end
	    (if (re-search-forward end-re limit 'move)
		(goto-char (match-beginning 0))
	      (point)))
	   (tblfm (let (acc)
		    (while (looking-at "[ \t]*#\\+TBLFM: +\\(.*\\)[ \t]*$")
		      (push (match-string-no-properties 1) acc)
		      (forward-line))
		    acc))
	   (pos-before-blank (point))
	   (end (progn (skip-chars-forward " \r\t\n" limit)
		       (if (eobp) (point) (line-beginning-position)))))
      (org-element-create
       'table
       (nconc
	(list :begin begin
	      :end end
	      :type type
	      :tblfm tblfm
	      ;; Only `org' tables have contents.  `table.el' tables
	      ;; use a `:value' property to store raw table as
	      ;; a string.
	      :contents-begin (and (eq type 'org) table-begin)
	      :contents-end (and (eq type 'org) table-end)
	      :value (and (eq type 'table.el)
                          (org-element-deferred-create
                           t #'org-element--substring
                           (- table-begin begin)
                           (- table-end begin)))
	      :post-blank (count-lines pos-before-blank end)
	      :post-affiliated table-begin)
	(cdr affiliated))))))