Function: org-ascii--build-title
org-ascii--build-title is a byte-compiled function defined in
ox-ascii.el.gz.
Signature
(org-ascii--build-title ELEMENT INFO TEXT-WIDTH &optional UNDERLINE NOTAGS TOC)
Documentation
Format ELEMENT title and return it.
ELEMENT is either an headline or inlinetask element. INFO is
a plist used as a communication channel. TEXT-WIDTH is an
integer representing the maximum length of a line.
When optional argument UNDERLINE is non-nil, underline title,
without the tags, according to org-ascii-underline(var)/org-ascii-underline(fun)
specifications.
If optional argument NOTAGS is non-nil, no tags will be added to the title.
When optional argument TOC is non-nil, use optional title if
possible. It doesn't apply to inlinetask elements.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ox-ascii.el.gz
(defun org-ascii--build-title
(element info text-width &optional underline notags toc)
"Format ELEMENT title and return it.
ELEMENT is either an `headline' or `inlinetask' element. INFO is
a plist used as a communication channel. TEXT-WIDTH is an
integer representing the maximum length of a line.
When optional argument UNDERLINE is non-nil, underline title,
without the tags, according to `org-ascii-underline'
specifications.
If optional argument NOTAGS is non-nil, no tags will be added to
the title.
When optional argument TOC is non-nil, use optional title if
possible. It doesn't apply to `inlinetask' elements."
(let* ((headlinep (eq (org-element-type element) 'headline))
(numbers
;; Numbering is specific to headlines.
(and headlinep
(org-export-numbered-headline-p element info)
(let ((numbering (org-export-get-headline-number element info)))
(if toc (format "%d. " (org-last numbering))
(concat (mapconcat #'number-to-string numbering ".")
" ")))))
(text
(org-trim
(org-export-data
(if (and toc headlinep) (org-export-get-alt-title element info)
(org-element-property :title element))
info)))
(todo
(and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property :todo-keyword element)))
(and todo (concat (org-export-data todo info) " ")))))
(tags (and (not notags)
(plist-get info :with-tags)
(let ((tag-list (org-export-get-tags element info)))
(and tag-list
(org-make-tag-string tag-list)))))
(priority
(and (plist-get info :with-priority)
(let ((char (org-element-property :priority element)))
(and char (format "(#%c) " char)))))
(first-part (concat numbers todo priority text)))
(concat
first-part
;; Align tags, if any.
(when tags
(format
(format " %%%ds"
(max (- text-width (1+ (string-width first-part)))
(string-width tags)))
tags))
;; Maybe underline text, if ELEMENT type is `headline' and an
;; underline character has been defined.
(when (and underline headlinep)
(let ((under-char
(nth (1- (org-export-get-relative-level element info))
(cdr (assq (plist-get info :ascii-charset)
(plist-get info :ascii-underline))))))
(and under-char
(concat "\n"
(make-string (/ (string-width first-part)
(char-width under-char))
under-char))))))))