ox-ascii: Use options instead of defcustoms in code

* lisp/ox-ascii.el (org-ascii--current-text-width,
  org-ascii--build-title, org-ascii--build-toc,
  org-ascii--list-listings, org-ascii--list-tables,
  org-ascii-template--document-title, org-ascii-inner-template,
  org-ascii-template, org-ascii-code, org-ascii-drawer,
  org-ascii-headline, org-ascii-inline-src-block,
  org-ascii-format-inlinetask-default, org-ascii-inlinetask,
  org-ascii-link, org-ascii-paragraph, org-ascii-quote-block,
  org-ascii-section, org-ascii-src-block, org-ascii-table,
  org-ascii--table-cell-width, org-ascii-table-cell,
  org-ascii-verbatim, org-ascii-verse-block,
  org-ascii-filter-headline-blank-lines,
  org-ascii-filter-paragraph-spacing): Use options instead of
  hard coded variables.
This commit is contained in:
Nicolas Goaziou 2014-07-25 13:48:28 +02:00
parent f4455f4902
commit dd6b4ffcef
1 changed files with 145 additions and 132 deletions

View File

@ -543,11 +543,12 @@ INFO is a plist used as a communication channel."
INFO is a plist used as a communication channel." INFO is a plist used as a communication channel."
(case (org-element-type element) (case (org-element-type element)
;; Elements with an absolute width: `headline' and `inlinetask'. ;; Elements with an absolute width: `headline' and `inlinetask'.
(inlinetask org-ascii-inlinetask-width) (inlinetask (plist-get info :ascii-inlinetask-width))
(headline (headline
(- org-ascii-text-width (- (plist-get info :ascii-text-width)
(let ((low-level-rank (org-export-low-level-p element info))) (let ((low-level-rank (org-export-low-level-p element info)))
(if low-level-rank (* low-level-rank 2) org-ascii-global-margin)))) (if low-level-rank (* low-level-rank 2)
(plist-get info :ascii-global-margin)))))
;; Elements with a relative width: store maximum text width in ;; Elements with a relative width: store maximum text width in
;; TOTAL-WIDTH. ;; TOTAL-WIDTH.
(otherwise (otherwise
@ -557,10 +558,10 @@ INFO is a plist used as a communication channel."
(total-width (total-width
(if (loop for parent in genealogy (if (loop for parent in genealogy
thereis (eq (org-element-type parent) 'inlinetask)) thereis (eq (org-element-type parent) 'inlinetask))
org-ascii-inlinetask-width (plist-get info :ascii-inlinetask-width)
;; No inlinetask: Remove global margin from text width. ;; No inlinetask: Remove global margin from text width.
(- org-ascii-text-width (- (plist-get info :ascii-text-width)
org-ascii-global-margin (plist-get info :ascii-global-margin)
(let ((parent (org-export-get-parent-headline element))) (let ((parent (org-export-get-parent-headline element)))
;; Inner margin doesn't apply to text before first ;; Inner margin doesn't apply to text before first
;; headline. ;; headline.
@ -571,7 +572,7 @@ INFO is a plist used as a communication channel."
;; low level headlines, since they've got their ;; low level headlines, since they've got their
;; own indentation mechanism. ;; own indentation mechanism.
(if low-level-rank (* low-level-rank 2) (if low-level-rank (* low-level-rank 2)
org-ascii-inner-margin)))))))) (plist-get info :ascii-inner-margin)))))))))
(- total-width (- total-width
;; Each `quote-block' and `verse-block' above narrows text ;; Each `quote-block' and `verse-block' above narrows text
;; width by twice the standard margin size. ;; width by twice the standard margin size.
@ -579,7 +580,7 @@ INFO is a plist used as a communication channel."
when (memq (org-element-type parent) when (memq (org-element-type parent)
'(quote-block verse-block)) '(quote-block verse-block))
count parent) count parent)
2 org-ascii-quote-margin) 2 (plist-get info :ascii-quote-margin))
;; Text width within a plain-list is restricted by ;; Text width within a plain-list is restricted by
;; indentation of current item. If that's the case, ;; indentation of current item. If that's the case,
;; compute it with the help of `:structure' property from ;; compute it with the help of `:structure' property from
@ -685,7 +686,7 @@ possible. It doesn't apply to `inlinetask' elements."
(let ((under-char (let ((under-char
(nth (1- (org-export-get-relative-level element info)) (nth (1- (org-export-get-relative-level element info))
(cdr (assq (plist-get info :ascii-charset) (cdr (assq (plist-get info :ascii-charset)
org-ascii-underline))))) (plist-get info :ascii-underline))))))
(and under-char (and under-char
(concat "\n" (concat "\n"
(make-string (/ (string-width first-part) (make-string (/ (string-width first-part)
@ -742,7 +743,8 @@ which the table of contents generation has been initiated."
"\n\n" "\n\n"
(let ((text-width (let ((text-width
(if keyword (org-ascii--current-text-width keyword info) (if keyword (org-ascii--current-text-width keyword info)
(- org-ascii-text-width org-ascii-global-margin)))) (- (plist-get info :ascii-text-width)
(plist-get info :ascii-global-margin)))))
(mapconcat (mapconcat
(lambda (headline) (lambda (headline)
(let* ((level (org-export-get-relative-level headline info)) (let* ((level (org-export-get-relative-level headline info))
@ -769,7 +771,8 @@ generation. INFO is a plist used as a communication channel."
"\n\n" "\n\n"
(let ((text-width (let ((text-width
(if keyword (org-ascii--current-text-width keyword info) (if keyword (org-ascii--current-text-width keyword info)
(- org-ascii-text-width org-ascii-global-margin))) (- (plist-get info :ascii-text-width)
(plist-get info :ascii-global-margin))))
;; Use a counter instead of retrieving ordinal of each ;; Use a counter instead of retrieving ordinal of each
;; src-block. ;; src-block.
(count 0)) (count 0))
@ -808,7 +811,8 @@ generation. INFO is a plist used as a communication channel."
"\n\n" "\n\n"
(let ((text-width (let ((text-width
(if keyword (org-ascii--current-text-width keyword info) (if keyword (org-ascii--current-text-width keyword info)
(- org-ascii-text-width org-ascii-global-margin))) (- (plist-get info :ascii-text-width)
(plist-get info :ascii-global-margin))))
;; Use a counter instead of retrieving ordinal of each ;; Use a counter instead of retrieving ordinal of each
;; src-block. ;; src-block.
(count 0)) (count 0))
@ -927,10 +931,10 @@ INFO is a plist used as a communication channel."
(defun org-ascii-template--document-title (info) (defun org-ascii-template--document-title (info)
"Return document title, as a string. "Return document title, as a string.
INFO is a plist used as a communication channel." INFO is a plist used as a communication channel."
(let* ((text-width org-ascii-text-width) (let* ((text-width (plist-get info :ascii-text-width))
;; Links in the title will not be resolved later, so we make ;; Links in the title will not be resolved later, so we make
;; sure their path is located right after them. ;; sure their path is located right after them.
(org-ascii-links-to-notes nil) (info (org-combine-plists info '(:ascii-links-to-notes nil)))
(title (org-export-data (plist-get info :title) info)) (title (org-export-data (plist-get info :title) info))
(author (and (plist-get info :with-author) (author (and (plist-get info :with-author)
(let ((auth (plist-get info :author))) (let ((auth (plist-get info :author)))
@ -1003,81 +1007,84 @@ INFO is a plist used as a communication channel."
CONTENTS is the transcoded contents string. INFO is a plist CONTENTS is the transcoded contents string. INFO is a plist
holding export options." holding export options."
(org-element-normalize-string (org-element-normalize-string
(org-ascii--indent-string (let ((global-margin (plist-get info :ascii-global-margin)))
(concat (org-ascii--indent-string
;; 1. Document's body. (concat
contents ;; 1. Document's body.
;; 2. Footnote definitions. contents
(let ((definitions (org-export-collect-footnote-definitions ;; 2. Footnote definitions.
(plist-get info :parse-tree) info)) (let ((definitions (org-export-collect-footnote-definitions
;; Insert full links right inside the footnote definition (plist-get info :parse-tree) info))
;; as they have no chance to be inserted later. ;; Insert full links right inside the footnote definition
(org-ascii-links-to-notes nil)) ;; as they have no chance to be inserted later.
(when definitions (info (org-combine-plists info '(:ascii-links-to-notes nil))))
(concat (when definitions
"\n\n\n" (concat
(let ((title (org-ascii--translate "Footnotes" info))) "\n\n\n"
(concat (let ((title (org-ascii--translate "Footnotes" info)))
title "\n" (concat
(make-string title "\n"
(string-width title) (make-string
(if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_)))) (string-width title)
"\n\n" (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))))
(let ((text-width (- org-ascii-text-width org-ascii-global-margin))) "\n\n"
(mapconcat (let ((text-width (- (plist-get info :ascii-text-width)
(lambda (ref) global-margin)))
(let ((id (format "[%s] " (car ref)))) (mapconcat
;; Distinguish between inline definitions and (lambda (ref)
;; full-fledged definitions. (let ((id (format "[%s] " (car ref))))
(org-trim ;; Distinguish between inline definitions and
(let ((def (nth 2 ref))) ;; full-fledged definitions.
(if (eq (org-element-type def) 'org-data) (org-trim
;; Full-fledged definition: footnote ID is (let ((def (nth 2 ref)))
;; inserted inside the first parsed paragraph (if (eq (org-element-type def) 'org-data)
;; (FIRST), if any, to be sure filling will ;; Full-fledged definition: footnote ID is
;; take it into consideration. ;; inserted inside the first parsed
(let ((first (car (org-element-contents def)))) ;; paragraph (FIRST), if any, to be sure
(if (not (eq (org-element-type first) 'paragraph)) ;; filling will take it into consideration.
(concat id "\n" (org-export-data def info)) (let ((first (car (org-element-contents def))))
(push id (nthcdr 2 first)) (if (not (eq (org-element-type first) 'paragraph))
(org-export-data def info))) (concat id "\n" (org-export-data def info))
;; Fill paragraph once footnote ID is inserted (push id (nthcdr 2 first))
;; in order to have a correct length for first (org-export-data def info)))
;; line. ;; Fill paragraph once footnote ID is inserted
(org-ascii--fill-string ;; in order to have a correct length for first
(concat id (org-export-data def info)) ;; line.
text-width info)))))) (org-ascii--fill-string
definitions "\n\n")))))) (concat id (org-export-data def info))
org-ascii-global-margin))) text-width info))))))
definitions "\n\n"))))))
global-margin))))
(defun org-ascii-template (contents info) (defun org-ascii-template (contents info)
"Return complete document string after ASCII conversion. "Return complete document string after ASCII conversion.
CONTENTS is the transcoded contents string. INFO is a plist CONTENTS is the transcoded contents string. INFO is a plist
holding export options." holding export options."
(concat (let ((global-margin (plist-get info :ascii-global-margin)))
;; 1. Build title block. (concat
(org-ascii--indent-string ;; 1. Build title block.
(concat (org-ascii-template--document-title info) (org-ascii--indent-string
;; 2. Table of contents. (concat (org-ascii-template--document-title info)
(let ((depth (plist-get info :with-toc))) ;; 2. Table of contents.
(when depth (let ((depth (plist-get info :with-toc)))
(concat (when depth
(org-ascii--build-toc info (and (wholenump depth) depth)) (concat
"\n\n\n")))) (org-ascii--build-toc info (and (wholenump depth) depth))
org-ascii-global-margin) "\n\n\n"))))
;; 3. Document's body. global-margin)
contents ;; 3. Document's body.
;; 4. Creator. Ignore `comment' value as there are no comments in contents
;; ASCII. Justify it to the bottom right. ;; 4. Creator. Ignore `comment' value as there are no comments in
(org-ascii--indent-string ;; ASCII. Justify it to the bottom right.
(let ((creator-info (plist-get info :with-creator)) (org-ascii--indent-string
(text-width (- org-ascii-text-width org-ascii-global-margin))) (let ((creator-info (plist-get info :with-creator))
(unless (or (not creator-info) (eq creator-info 'comment)) (text-width (- (plist-get info :ascii-text-width) global-margin)))
(concat (unless (or (not creator-info) (eq creator-info 'comment))
"\n\n\n" (concat
(org-ascii--fill-string "\n\n\n"
(plist-get info :creator) text-width info 'right)))) (org-ascii--fill-string
org-ascii-global-margin))) (plist-get info :creator) text-width info 'right))))
global-margin))))
(defun org-ascii--translate (s info) (defun org-ascii--translate (s info)
"Translate string S according to specified language and charset. "Translate string S according to specified language and charset.
@ -1135,7 +1142,8 @@ information."
"Return a CODE object from Org to ASCII. "Return a CODE object from Org to ASCII.
CONTENTS is nil. INFO is a plist holding contextual CONTENTS is nil. INFO is a plist holding contextual
information." information."
(format org-ascii-verbatim-format (org-element-property :value code))) (format (plist-get info :ascii-verbatim-format)
(org-element-property :value code)))
;;;; Drawer ;;;; Drawer
@ -1146,7 +1154,8 @@ CONTENTS holds the contents of the block. INFO is a plist
holding contextual information." holding contextual information."
(let ((name (org-element-property :drawer-name drawer)) (let ((name (org-element-property :drawer-name drawer))
(width (org-ascii--current-text-width drawer info))) (width (org-ascii--current-text-width drawer info)))
(funcall org-ascii-format-drawer-function name contents width))) (funcall (plist-get info :ascii-format-drawer-function)
name contents width)))
;;;; Dynamic Block ;;;; Dynamic Block
@ -1241,8 +1250,9 @@ holding contextual information."
;; original buffer's spacing. ;; original buffer's spacing.
(pre-blanks (pre-blanks
(make-string (make-string
(if org-ascii-headline-spacing (car org-ascii-headline-spacing) (or (car (plist-get info :ascii-headline-spacing))
(org-element-property :pre-blank headline)) ?\n)) (org-element-property :pre-blank headline))
?\n))
;; Even if HEADLINE has no section, there might be some ;; Even if HEADLINE has no section, there might be some
;; links in its title that we shouldn't forget to describe. ;; links in its title that we shouldn't forget to describe.
(links (links
@ -1256,7 +1266,7 @@ holding contextual information."
(concat (concat
;; Bullet. ;; Bullet.
(let ((bullets (cdr (assq (plist-get info :ascii-charset) (let ((bullets (cdr (assq (plist-get info :ascii-charset)
org-ascii-bullets)))) (plist-get info :ascii-bullets)))))
(char-to-string (char-to-string
(nth (mod (1- low-level-rank) (length bullets)) bullets))) (nth (mod (1- low-level-rank) (length bullets)) bullets)))
" " " "
@ -1298,7 +1308,7 @@ information."
"Transcode an INLINE-SRC-BLOCK element from Org to ASCII. "Transcode an INLINE-SRC-BLOCK element from Org to ASCII.
CONTENTS holds the contents of the item. INFO is a plist holding CONTENTS holds the contents of the item. INFO is a plist holding
contextual information." contextual information."
(format org-ascii-verbatim-format (format (plist-get info :ascii-verbatim-format)
(org-element-property :value inline-src-block))) (org-element-property :value inline-src-block)))
@ -1310,7 +1320,7 @@ contextual information."
See `org-ascii-format-inlinetask-function' for a description See `org-ascii-format-inlinetask-function' for a description
of the parameters." of the parameters."
(let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)) (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
(width (or width org-ascii-inlinetask-width))) (width (or width (plist-get info :ascii-inlinetask-width))))
(org-ascii--indent-string (org-ascii--indent-string
(concat (concat
;; Top line, with an additional blank line if not in UTF-8. ;; Top line, with an additional blank line if not in UTF-8.
@ -1328,9 +1338,9 @@ of the parameters."
;; Bottom line. ;; Bottom line.
(make-string width (if utf8p ?━ ?_))) (make-string width (if utf8p ?━ ?_)))
;; Flush the inlinetask to the right. ;; Flush the inlinetask to the right.
(- org-ascii-text-width org-ascii-global-margin (- (plist-get info :ascii-text-width) (plist-get info :ascii-global-margin)
(if (not (org-export-get-parent-headline inlinetask)) 0 (if (not (org-export-get-parent-headline inlinetask)) 0
org-ascii-inner-margin) (plist-get info :ascii-inner-margin))
(org-ascii--current-text-width inlinetask info))))) (org-ascii--current-text-width inlinetask info)))))
(defun org-ascii-inlinetask (inlinetask contents info) (defun org-ascii-inlinetask (inlinetask contents info)
@ -1338,7 +1348,7 @@ of the parameters."
CONTENTS holds the contents of the block. INFO is a plist CONTENTS holds the contents of the block. INFO is a plist
holding contextual information." holding contextual information."
(let ((width (org-ascii--current-text-width inlinetask info))) (let ((width (org-ascii--current-text-width inlinetask info)))
(funcall org-ascii-format-inlinetask-function (funcall (plist-get info :ascii-format-inlinetask-function)
;; todo. ;; todo.
(and (plist-get info :with-todo-keywords) (and (plist-get info :with-todo-keywords)
(let ((todo (org-element-property (let ((todo (org-element-property
@ -1506,9 +1516,9 @@ INFO is a plist holding contextual information."
(mapconcat 'number-to-string number ".")))))))) (mapconcat 'number-to-string number "."))))))))
(t (t
(if (not (org-string-nw-p desc)) (format "[%s]" raw-link) (if (not (org-string-nw-p desc)) (format "[%s]" raw-link)
(concat (concat (format "[%s]" desc)
(format "[%s]" desc) (and (not (plist-get info :ascii-links-to-notes))
(unless org-ascii-links-to-notes (format " (%s)" raw-link)))))))) (format " (%s)" raw-link))))))))
;;;; Node Properties ;;;; Node Properties
@ -1530,14 +1540,15 @@ information."
CONTENTS is the contents of the paragraph, as a string. INFO is CONTENTS is the contents of the paragraph, as a string. INFO is
the plist used as a communication channel." the plist used as a communication channel."
(org-ascii--justify-element (org-ascii--justify-element
(if (not (wholenump org-ascii-indented-line-width)) contents (let ((indented-line-width (plist-get info :ascii-indented-line-width)))
(concat (if (not (wholenump indented-line-width)) contents
;; Do not indent first paragraph in a section. (concat
(unless (and (not (org-export-get-previous-element paragraph info)) ;; Do not indent first paragraph in a section.
(eq (org-element-type (org-export-get-parent paragraph)) (unless (and (not (org-export-get-previous-element paragraph info))
'section)) (eq (org-element-type (org-export-get-parent paragraph))
(make-string org-ascii-indented-line-width ?\s)) 'section))
(replace-regexp-in-string "\\`[ \t]+" "" contents))) (make-string indented-line-width ?\s))
(replace-regexp-in-string "\\`[ \t]+" "" contents))))
paragraph info)) paragraph info))
@ -1614,7 +1625,7 @@ holding contextual information."
"Transcode a QUOTE-BLOCK element from Org to ASCII. "Transcode a QUOTE-BLOCK element from Org to ASCII.
CONTENTS holds the contents of the block. INFO is a plist CONTENTS holds the contents of the block. INFO is a plist
holding contextual information." holding contextual information."
(org-ascii--indent-string contents org-ascii-quote-margin)) (org-ascii--indent-string contents (plist-get info :ascii-quote-margin)))
;;;; Radio Target ;;;; Radio Target
@ -1635,7 +1646,7 @@ contextual information."
(org-ascii--indent-string (org-ascii--indent-string
(concat (concat
contents contents
(when org-ascii-links-to-notes (when (plist-get info :ascii-links-to-notes)
;; Add list of links at the end of SECTION. ;; Add list of links at the end of SECTION.
(let ((links (org-ascii--describe-links (let ((links (org-ascii--describe-links
(org-ascii--unique-links section info) (org-ascii--unique-links section info)
@ -1645,7 +1656,7 @@ contextual information."
;; Do not apply inner margin if parent headline is low level. ;; Do not apply inner margin if parent headline is low level.
(let ((headline (org-export-get-parent-headline section))) (let ((headline (org-export-get-parent-headline section)))
(if (or (not headline) (org-export-low-level-p headline info)) 0 (if (or (not headline) (org-export-low-level-p headline info)) 0
org-ascii-inner-margin)))) (plist-get info :ascii-inner-margin)))))
;;;; Special Block ;;;; Special Block
@ -1667,14 +1678,14 @@ holding contextual information."
CONTENTS holds the contents of the item. INFO is a plist holding CONTENTS holds the contents of the item. INFO is a plist holding
contextual information." contextual information."
(let ((caption (org-ascii--build-caption src-block info)) (let ((caption (org-ascii--build-caption src-block info))
(caption-above-p (plist-get info :ascii-caption-above))
(code (org-export-format-code-default src-block info))) (code (org-export-format-code-default src-block info)))
(if (equal code "") "" (if (equal code "") ""
(org-ascii--justify-element (org-ascii--justify-element
(concat (concat
(when (and caption org-ascii-caption-above) (concat caption "\n")) (and caption caption-above-p (concat caption "\n"))
(org-ascii--box-string code info) (org-ascii--box-string code info)
(when (and caption (not org-ascii-caption-above)) (and caption (not caption-above-p) (concat "\n" caption)))
(concat "\n" caption)))
src-block info)))) src-block info))))
@ -1723,14 +1734,15 @@ holding contextual information."
"Transcode a TABLE element from Org to ASCII. "Transcode a TABLE element from Org to ASCII.
CONTENTS is the contents of the table. INFO is a plist holding CONTENTS is the contents of the table. INFO is a plist holding
contextual information." contextual information."
(let ((caption (org-ascii--build-caption table info))) (let ((caption (org-ascii--build-caption table info))
(caption-above-p (plist-get info :ascii-caption-above)))
(org-ascii--justify-element (org-ascii--justify-element
(concat (concat
;; Possibly add a caption string above. ;; Possibly add a caption string above.
(when (and caption org-ascii-caption-above) (concat caption "\n")) (and caption caption-above-p (concat caption "\n"))
;; Insert table. Note: "table.el" tables are left unmodified. ;; Insert table. Note: "table.el" tables are left unmodified.
(cond ((eq (org-element-property :type table) 'org) contents) (cond ((eq (org-element-property :type table) 'org) contents)
((and org-ascii-table-use-ascii-art ((and (plist-get info :ascii-table-use-ascii-art)
(eq (plist-get info :ascii-charset) 'utf-8) (eq (plist-get info :ascii-charset) 'utf-8)
(require 'ascii-art-to-unicode nil t)) (require 'ascii-art-to-unicode nil t))
(with-temp-buffer (with-temp-buffer
@ -1743,7 +1755,7 @@ contextual information."
(buffer-substring (point-min) (point)))) (buffer-substring (point-min) (point))))
(t (org-remove-indentation (org-element-property :value table)))) (t (org-remove-indentation (org-element-property :value table))))
;; Possible add a caption string below. ;; Possible add a caption string below.
(and (not org-ascii-caption-above) caption)) (and (not caption-above-p) caption))
table info))) table info)))
@ -1770,12 +1782,13 @@ are ignored."
(plist-put info :ascii-table-cell-width-cache (plist-put info :ascii-table-cell-width-cache
(make-hash-table :test 'equal))) (make-hash-table :test 'equal)))
:ascii-table-cell-width-cache))) :ascii-table-cell-width-cache)))
(key (cons table col))) (key (cons table col))
(widenp (plist-get info :ascii-table-widen-columns)))
(or (gethash key cache) (or (gethash key cache)
(puthash (puthash
key key
(let ((cookie-width (org-export-table-cell-width table-cell info))) (let ((cookie-width (org-export-table-cell-width table-cell info)))
(or (and (not org-ascii-table-widen-columns) cookie-width) (or (and (not widenp) cookie-width)
(let ((contents-width (let ((contents-width
(let ((max-width 0)) (let ((max-width 0))
(org-element-map table 'table-row (org-element-map table 'table-row
@ -1790,8 +1803,7 @@ are ignored."
info) info)
max-width))) max-width)))
(cond ((not cookie-width) contents-width) (cond ((not cookie-width) contents-width)
(org-ascii-table-widen-columns (widenp (max cookie-width contents-width))
(max cookie-width contents-width))
(t cookie-width))))) (t cookie-width)))))
cache)))) cache))))
@ -1805,7 +1817,7 @@ a communication channel."
;; each cell in the column. ;; each cell in the column.
(let ((width (org-ascii--table-cell-width table-cell info))) (let ((width (org-ascii--table-cell-width table-cell info)))
;; When contents are too large, truncate them. ;; When contents are too large, truncate them.
(unless (or org-ascii-table-widen-columns (unless (or (plist-get info :ascii-table-widen-columns)
(<= (string-width (or contents "")) width)) (<= (string-width (or contents "")) width))
(setq contents (concat (substring contents 0 (- width 2)) "=>"))) (setq contents (concat (substring contents 0 (- width 2)) "=>")))
;; Align contents correctly within the cell. ;; Align contents correctly within the cell.
@ -1899,7 +1911,7 @@ holding contextual information."
(defun org-ascii-verbatim (verbatim contents info) (defun org-ascii-verbatim (verbatim contents info)
"Return a VERBATIM object from Org to ASCII. "Return a VERBATIM object from Org to ASCII.
CONTENTS is nil. INFO is a plist holding contextual information." CONTENTS is nil. INFO is a plist holding contextual information."
(format org-ascii-verbatim-format (format (plist-get info :ascii-verbatim-format)
(org-element-property :value verbatim))) (org-element-property :value verbatim)))
@ -1912,7 +1924,7 @@ contextual information."
(let ((verse-width (org-ascii--current-text-width verse-block info))) (let ((verse-width (org-ascii--current-text-width verse-block info)))
(org-ascii--indent-string (org-ascii--indent-string
(org-ascii--justify-element contents verse-block info) (org-ascii--justify-element contents verse-block info)
org-ascii-quote-margin))) (plist-get info :ascii-quote-margin))))
@ -1927,9 +1939,10 @@ plist containing the communication channel.
This function only applies to `ascii' back-end. See This function only applies to `ascii' back-end. See
`org-ascii-headline-spacing' for information." `org-ascii-headline-spacing' for information."
(if (not org-ascii-headline-spacing) headline (let ((headline-spacing (plist-get info :ascii-headline-spacing)))
(let ((blanks (make-string (1+ (cdr org-ascii-headline-spacing)) ?\n))) (if (not headline-spacing) headline
(replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline)))) (let ((blanks (make-string (1+ (cdr headline-spacing)) ?\n)))
(replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline)))))
(defun org-ascii-filter-paragraph-spacing (tree back-end info) (defun org-ascii-filter-paragraph-spacing (tree back-end info)
"Filter controlling number of blank lines between paragraphs. "Filter controlling number of blank lines between paragraphs.
@ -1939,13 +1952,13 @@ back-end used for export. INFO is a plist used as
a communication channel. a communication channel.
See `org-ascii-paragraph-spacing' for information." See `org-ascii-paragraph-spacing' for information."
(when (wholenump org-ascii-paragraph-spacing) (let ((paragraph-spacing (plist-get info :ascii-paragraph-spacing)))
(org-element-map tree 'paragraph (when paragraph-spacing
(lambda (p) (org-element-map tree 'paragraph
(when (eq (org-element-type (org-export-get-next-element p info)) (lambda (p)
'paragraph) (when (eq (org-element-type (org-export-get-next-element p info))
(org-element-put-property 'paragraph)
p :post-blank org-ascii-paragraph-spacing))))) (org-element-put-property p :post-blank paragraph-spacing))))))
tree) tree)
(defun org-ascii-filter-comment-spacing (tree backend info) (defun org-ascii-filter-comment-spacing (tree backend info)