Function: org-ascii--justify-element
org-ascii--justify-element is a byte-compiled function defined in
ox-ascii.el.gz.
Signature
(org-ascii--justify-element CONTENTS ELEMENT INFO)
Documentation
Justify CONTENTS of ELEMENT.
INFO is a plist used as a communication channel. Justification is done according to the type of element. More accurately, paragraphs are filled and other elements are justified as blocks, that is according to the widest non blank line in CONTENTS.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-ascii.el.gz
(defun org-ascii--justify-element (contents element info)
"Justify CONTENTS of ELEMENT.
INFO is a plist used as a communication channel. Justification
is done according to the type of element. More accurately,
paragraphs are filled and other elements are justified as blocks,
that is according to the widest non blank line in CONTENTS."
(if (not (org-string-nw-p contents)) contents
(let ((text-width (org-ascii--current-text-width element info))
(how (org-ascii--current-justification element)))
(cond
((org-element-type-p element 'paragraph)
;; Paragraphs are treated specially as they need to be filled.
(org-ascii--fill-string contents text-width info how))
((eq how 'left) contents)
(t (with-temp-buffer
(insert contents)
(goto-char (point-min))
(catch 'exit
(let ((max-width 0))
;; Compute maximum width. Bail out if it is greater
;; than page width, since no justification is
;; possible.
(save-excursion
(while (not (eobp))
(unless (looking-at-p "[ \t]*$")
(end-of-line)
(let ((column (current-column)))
(cond
((>= column text-width) (throw 'exit contents))
((> column max-width) (setq max-width column)))))
(forward-line)))
;; Justify every line according to TEXT-WIDTH and
;; MAX-WIDTH.
(let ((offset (/ (- text-width max-width)
(if (eq how 'right) 1 2))))
(if (zerop offset) (throw 'exit contents)
(while (not (eobp))
(unless (looking-at-p "[ \t]*$")
(indent-to-column offset))
(forward-line)))))
(buffer-string))))))))