Function: eca-table--parse-row

eca-table--parse-row is a natively compiled function defined in eca-table.el.

Signature

(eca-table--parse-row LINE)

Documentation

Parse LINE into a list of cell contents.

Escaped pipes and pipes inside code spans do not end a cell. Supports rows with or without leading/trailing pipes.

Source Code

;; Defined in /nix/store/jklqzw6pzz6j4jrbv8wy0iwgi7jlrbld-emacs-packages-deps/share/emacs/site-lisp/elpa/eca-20260928.1827/eca-table.el
(defun eca-table--parse-row (line)
  "Parse LINE into a list of cell contents.
Escaped pipes and pipes inside code spans do not end a cell.
Supports rows with or without leading/trailing pipes."
  (with-temp-buffer
    (insert line)
    (goto-char (point-min))
    (let ((cells '())
          (cell-start nil))
      ;; Skip leading whitespace and optional first pipe
      (if (looking-at "[ \t]*|")
          (progn
            (goto-char (match-end 0))
            (setq cell-start (point)))
        (skip-chars-forward " \t")
        (setq cell-start (point)))
      (while (< (point) (point-max))
        (cond
         ;; Code span: pipes inside it are content
         ((eq (char-after) ?\`)
          (eca-table--skip-code-span))
         ;; Escaped character - skip next char (guard end of buffer)
         ((eq (char-after) ?\\)
          (forward-char (min 2 (- (point-max) (point)))))
         ;; Pipe - end of cell
         ((eq (char-after) ?|)
          (push (string-trim (buffer-substring-no-properties
                              cell-start (point)))
                cells)
          (forward-char 1)
          (setq cell-start (point)))
         (t (forward-char 1))))
      ;; Push trailing content if row lacks a trailing pipe
      (when (and cell-start (< cell-start (point-max)))
        (let ((trailing (string-trim
                         (buffer-substring-no-properties
                          cell-start (point-max)))))
          (unless (string-empty-p trailing)
            (push trailing cells))))
      (nreverse cells))))