Function: org-odt--strip-trailing-newlines

org-odt--strip-trailing-newlines is a byte-compiled function defined in ox-odt.el.gz.

Signature

(org-odt--strip-trailing-newlines DATA BACKEND INFO)

Documentation

Strip trailing newlines in DATA at the end of contents.

INFO is the communication channel.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-odt.el.gz
;;; Filters

;;; Plain text

;; Trailing newlines appear as spaces in ODT.
;; We do not want that in, for example, in paragraphs where
;; end of paragraph is already signaled by ODT tag.
(defun org-odt--strip-trailing-newlines (data _backend info)
  "Strip trailing newlines in DATA at the end of contents.
INFO is the communication channel."
  (org-element-map data org-element-all-elements
    (lambda (el)
      (when-let* ((last-child (car (last (org-element-contents el)))))
        (when (and (org-element-type-p last-child 'plain-text)
                   (string-suffix-p "\n" last-child))
          (when (length> last-child 1)
            (org-element-insert-before
             (substring last-child 0 (1- (length last-child)))
             last-child))
          (org-element-extract last-child))))
    info nil nil t)
  data)