Function: org-latex--plain-text-verse-block

org-latex--plain-text-verse-block is a byte-compiled function defined in ox-latex.el.gz.

Signature

(org-latex--plain-text-verse-block CONTENTS PLAIN-TEXT)

Documentation

Format CONTENTS if PLAIN-TEXT is inside verse environment.

INFO is the communication plist. Return CONTENTS unchanged when TEXT is not inside verse environment or when TEXT is a part of footnote reference.

In a verse environment, add a line break to each newline character and change each white space at beginning of a line into a normal space, calculated with \fontdimen2\font. One or more blank lines between lines are exported as a single blank line. If the :lines attribute is used, the last verse of each stanza ends with the string \!, according to the syntax of the verse package. The separation between stanzas can be controlled with the length \stanzaskip, of the aforementioned package. If the :literal attribute is used, all blank lines are preserved and exported as \vspace*{\baselineskip}, including the blank lines before or after CONTENTS.

Source Code

;; Defined in /usr/src/emacs/lisp/org/ox-latex.el.gz
;;;; Verse Block

(defun org-latex--plain-text-verse-block (contents plain-text)
  "Format CONTENTS if PLAIN-TEXT is inside verse environment.
INFO is the communication plist.
Return CONTENTS unchanged when TEXT is not inside verse environment or
when TEXT is a part of footnote reference.

In a verse environment, add a line break to each newline character and
change each white space at beginning of a line into a normal space,
calculated with `\\fontdimen2\\font'.  One or more blank lines between
lines are exported as a single blank line.  If the `:lines' attribute
is used, the last verse of each stanza ends with the string `\\!',
according to the syntax of the `verse' package.  The separation between
stanzas can be controlled with the length `\\stanzaskip', of the
aforementioned package.  If the `:literal' attribute is used, all
blank lines are preserved and exported as `\\vspace*{\\baselineskip}',
including the blank lines before or after CONTENTS."
  (if-let* ((verse-block (org-element-lineage plain-text 'verse-block))
            ;; VALUEFORM
            ((not (org-element-lineage plain-text 'footnote-reference))))
      (let* ((lin (org-export-read-attribute :attr_latex verse-block :lines))
             (lit (org-export-read-attribute :attr_latex verse-block :literal)))
	(replace-regexp-in-string
	 "^[ \t]+" (lambda (m) (format "\\hspace*{%d\\fontdimen2\\font}" (length m)))
	 (replace-regexp-in-string
          (if (not lit)
	      (rx-to-string
               `(seq (group "\\\\\n")
		     (1+ (group line-start (0+ space) "\\\\\n"))))
	    "^[ \t]*\\\\$")
	  (if (not lit)
	      (if lin "\\\\!\n\n" "\n\n")
	    "\\vspace*{\\baselineskip}")
	  (replace-regexp-in-string
	   "\\([ \t]*\\\\\\\\\\)?[ \t]*\n"
           "\\\\\n"
	   contents
           nil t)
          nil t)
         nil t))
    ;; Not in verse block, return CONTENTS unchanged.
    contents))