Function: org-odt-plain-text
org-odt-plain-text is a byte-compiled function defined in
ox-odt.el.gz.
Signature
(org-odt-plain-text TEXT INFO)
Documentation
Transcode a TEXT string from Org to ODT.
TEXT is the string to transcode. INFO is a plist holding contextual information.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-odt.el.gz
(defun org-odt-plain-text (text info)
"Transcode a TEXT string from Org to ODT.
TEXT is the string to transcode. INFO is a plist holding
contextual information."
(let ((output text))
;; Protect &, < and >.
(setq output (org-odt--encode-plain-text output t))
;; Handle smart quotes. Be sure to provide original string since
;; OUTPUT may have been modified.
(when (plist-get info :with-smart-quotes)
(setq output (org-export-activate-smart-quotes output :utf-8 info text)))
;; Convert special strings.
(when (plist-get info :with-special-strings)
(dolist (pair org-odt-special-string-regexps)
(setq output
(replace-regexp-in-string (car pair) (cdr pair) output t nil))))
;; Handle break preservation if required.
(if (plist-get info :preserve-breaks)
(setq output (replace-regexp-in-string
"\\(\\\\\\\\\\)?[ \t]*\n" "<text:line-break/>" output t))
;; OpenDocument schema recognizes newlines as spaces, which may
;; not be desired in scripts that do not separate words with
;; spaces (for example, Han script). `fill-region' is able to
;; handle such situations.
;; FIXME: The unnecessary spacing may still remain when a newline
;; is at a boundary between Org objects (e.g. italics markup
;; followed by newline).
(when (org-string-nw-p output) ; blank string needs not to be re-filled
(setq output
(with-temp-buffer
(save-match-data
(let ((leading (and (string-match (rx bos (1+ blank)) output)
(match-string 0 output)))
(trailing (and (string-match (rx (1+ blank) eos) output)
(match-string 0 output))))
(insert
(substring
output
(length leading)
(pcase (length trailing)
(0 nil)
(n (- n)))))
;; Unfill, retaining leading/trailing space.
(let ((fill-column most-positive-fixnum))
(fill-region (point-min) (point-max)))
(concat leading (buffer-string) trailing)))))))
;; Return value.
output))