org-e-ascii: Make margin for quoted text configurable
[org-mode.git] / EXPERIMENTAL / org-e-ascii.el
blob99fb7ea172c247ee517946ae8aa649ac0daef78d
1 ;;; org-e-ascii.el --- ASCII Back-End For Org Export Engine
3 ;; Copyright (C) 2012 Free Software Foundation, Inc.
5 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
6 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ;;; Commentary:
23 ;; This library implements an ASCII back-end for Org generic exporter.
25 ;; To test it, run
27 ;; M-: (org-export-to-buffer 'e-ascii "*Test e-ASCII*") RET
29 ;; in an Org mode buffer then switch to that buffer to see the ASCII
30 ;; export. See contrib/lisp/org-export.el for more details on how
31 ;; this exporter works.
33 ;;; Code:
35 (eval-when-compile (require 'cl))
37 (declare-function org-element-get-contents "org-element" (element))
38 (declare-function org-element-get-property "org-element" (property element))
39 (declare-function org-element-map "org-element"
40 (data types fun &optional info first-match))
41 (declare-function org-element-time-stamp-interpreter
42 "org-element" (time-stamp contents))
44 (declare-function org-export-clean-table "org-export" (table specialp))
45 (declare-function org-export-collect-footnote-definitions
46 "org-export" (data info))
47 (declare-function org-export-collect-headlines "org-export" (info &optional n))
48 (declare-function org-export-collect-listings "org-export" (info))
49 (declare-function org-export-collect-tables "org-export" (info))
50 (declare-function org-export-data "org-export" (data backend info))
51 (declare-function org-export-expand-macro "org-export" (macro info))
52 (declare-function org-export-get-coderef-format "org-export" (path desc))
53 (declare-function org-export-get-footnote-number "org-export" (footnote info))
54 (declare-function org-export-get-headline-number "org-export" (headline info))
55 (declare-function org-export-get-ordinal "org-export"
56 (element info &optional types within-section predicate))
57 (declare-function org-export-get-parent-headline "org-export" (blob info))
58 (declare-function org-export-get-relative-level "org-export" (headline info))
59 (declare-function org-export-handle-code
60 "org-export" (element info &optional num-fmt ref-fmt delayed))
61 (declare-function org-export-included-file "org-export" (keyword backend info))
62 (declare-function org-export-low-level-p "org-export" (headline info))
63 (declare-function org-export-output-file-name "org-export"
64 (extension &optional subtreep pub-dir))
65 (declare-function org-export-resolve-coderef "org-export" (ref info))
66 (declare-function org-export-resolve-fuzzy-link "org-export" (link info))
67 (declare-function org-export-resolve-id-link "org-export" (link info))
68 (declare-function org-export-secondary-string
69 "org-export" (secondary backend info))
70 (declare-function org-export-table-format-info "org-export" (table))
71 (declare-function
72 org-export-to-file "org-export"
73 (backend file &optional subtreep visible-only body-only ext-plist))
77 ;;; Internal Variables
79 ;; The following setting won't allow to modify preferred charset
80 ;; through a buffer keyword or an option item, but, since the property
81 ;; will appear in communication channel nonetheless, it allows to
82 ;; override `org-e-ascii-charset' variable on the fly by the ext-plist
83 ;; mechanism.
85 ;; We also install a developer filter for headlines, in order to
86 ;; control blank lines in output string.
88 (defconst org-e-ascii-option-alist
89 '((:ascii-charset nil nil org-e-ascii-charset)
90 (:filter-headline nil nil (cons
91 'org-e-ascii-filter-headline-blank-lines
92 org-export-filter-headline-functions)))
93 "Alist between ASCII export properties and ways to set them.
94 See `org-export-option-alist' for more information on the
95 structure or the values.")
97 (defconst org-e-ascii-dictionary
98 '(("Footnotes\n"
99 ("en"
100 :ascii "Footnotes\n"
101 :latin1 "Footnotes\n"
102 :utf-8 "Footnotes\n")
103 ("fr"
104 :ascii "Notes de bas de page\n"
105 :latin1 "Notes de bas de page\n"
106 :utf-8 "Notes de bas de page\n"))
107 ("Listing %d: %s"
108 ("en"
109 :ascii "Listing %d: %s"
110 :latin1 "Listing %d: %s"
111 :utf-8 "Listing %d: %s")
112 ("fr"
113 :ascii "Programme %d : %s"
114 :latin1 "Programme %d : %s"
115 :utf-8 "Programme nº %d : %s"))
116 ("List Of Listings\n"
117 ("en"
118 :ascii "List Of Listings\n"
119 :latin1 "List Of Listings\n"
120 :utf-8 "List Of Listings\n")
121 ("fr"
122 :ascii "Liste des programmes\n"
123 :latin1 "Liste des programmes\n"
124 :utf-8 "Liste des programmes\n"))
125 ("List Of Tables\n"
126 ("en"
127 :ascii "List Of Tables\n"
128 :latin1 "List Of Tables\n"
129 :utf-8 "List Of Tables\n")
130 ("fr"
131 :ascii "Liste des tableaux\n"
132 :latin1 "Liste des tableaux\n"
133 :utf-8 "Liste des tableaux\n"))
134 ("Listing %d: "
135 ("en"
136 :ascii "Listing %d: "
137 :latin1 "Listing %d: "
138 :utf-8 "Listing %d: ")
139 ("fr"
140 :ascii "Programme %d : "
141 :latin1 "Programme %d : "
142 :utf-8 "Programme nº %d : "))
143 ("Table Of Contents\n"
144 ("en"
145 :ascii "Table Of Contents\n"
146 :latin1 "Table Of Contents\n"
147 :utf-8 "Table Of Contents\n")
148 ("fr"
149 :ascii "Sommaire\n"
150 :latin1 "Table des matières\n"
151 :utf-8 "Table des matières\n"))
152 ("Table %d: %s"
153 ("en"
154 :ascii "Table %d: %s"
155 :latin1 "Table %d: %s"
156 :utf-8 "Table %d: %s")
157 ("fr"
158 :ascii "Tableau %d : %s"
159 :latin1 "Tableau %d : %s"
160 :utf-8 "Tableau nº %d : %s"))
161 ("See section %s"
162 ("en"
163 :ascii "See section %s"
164 :latin1 "See section %s"
165 :utf-8 "See section %s")
166 ("fr"
167 :ascii "cf. section %s"
168 :latin1 "cf. section %s"
169 :utf-8 "cf. section %s"))
170 ("Table %d: "
171 ("en"
172 :ascii "Table %d: "
173 :latin1 "Table %d: "
174 :utf-8 "Table %d: ")
175 ("fr"
176 :ascii "Tableau %d : "
177 :latin1 "Tableau %d : "
178 :utf-8 "Tableau nº %d : "))
179 ("Unknown reference"
180 ("en"
181 :ascii "Unknown reference"
182 :latin1 "Unknown reference"
183 :utf-8 "Unknown reference")
184 ("fr"
185 :ascii "Destination inconnue"
186 :latin1 "Référence inconnue"
187 :utf-8 "Référence inconnue")))
188 "Dictionary for ASCII back-end.
190 Alist whose car is the string to translate and cdr is an alist
191 whose car is the language string and cdr is a plist whose
192 properties are possible charsets and value the translated term.
194 It is used as a database for `org-e-ascii--translate'.")
198 ;;; User Configurable Variables
200 (defgroup org-export-e-ascii nil
201 "Options for exporting Org mode files to ASCII."
202 :tag "Org Export ASCII"
203 :group 'org-export)
205 (defcustom org-e-ascii-text-width 72
206 "Maximum width of exported text.
207 This number includes margin size, as set in
208 `org-e-ascii-global-margin'."
209 :group 'org-export-e-ascii
210 :type 'integer)
212 (defcustom org-e-ascii-global-margin 0
213 "Width of the left margin, in number of characters."
214 :group 'org-export-e-ascii
215 :type 'integer)
217 (defcustom org-e-ascii-inner-margin 2
218 "Width of the inner margin, in number of characters.
219 Inner margin is applied between each headline."
220 :group 'org-export-e-ascii
221 :type 'integer)
223 (defcustom org-e-ascii-quote-margin 6
224 "Width of margin used for quoting text, in characters.
225 This margin is applied on both sides of the text."
226 :group 'org-export-e-ascii
227 :type 'integer)
229 (defcustom org-e-ascii-inlinetask-width 30
230 "Width of inline tasks, in number of characters.
231 This number ignores any margin."
232 :group 'org-export-e-ascii
233 :type 'integer)
235 (defcustom org-e-ascii-headline-spacing '(1 . 2)
236 "Number of blank lines inserted around headlines.
238 This variable can be set to a cons cell. In that case, its car
239 represents the number of blank lines present before headline
240 contents whereas its cdr reflects the number of blank lines after
241 contents.
243 A nil value replicates the number of blank lines found in the
244 original Org buffer at the same place."
245 :group 'org-export-e-ascii
246 :type '(choice
247 (const :tag "Replicate original spacing" nil)
248 (cons :tag "Set an uniform spacing"
249 (integer :tag "Number of blank lines before contents")
250 (integer :tag "Number of blank lines after contents"))))
252 (defcustom org-e-ascii-charset 'ascii
253 "The charset allowed to represent various elements and objects.
254 Possible values are:
255 `ascii' Only use plain ASCII characters
256 `latin1' Include Latin-1 characters
257 `utf-8' Use all UTF-8 characters"
258 :group 'org-export-e-ascii
259 :type '(choice
260 (const :tag "ASCII" ascii)
261 (const :tag "Latin-1" latin1)
262 (const :tag "UTF-8" utf-8)))
264 (defcustom org-e-ascii-underline '((ascii ?= ?~ ?-)
265 (latin1 ?= ?~ ?-)
266 (utf-8 ?═ ?─ ?╌ ?┄ ?┈))
267 "Characters for underlining headings in ASCII export.
269 Alist whose key is a symbol among `ascii', `latin1' and `utf-8'
270 and whose value is a list of characters.
272 For each supported charset, this variable associates a sequence
273 of underline characters. In a sequence, the characters will be
274 used in order for headlines level 1, 2, ... If no character is
275 available for a given level, the headline won't be underlined."
276 :group 'org-export-e-ascii
277 :type '(list
278 (cons :tag "Underline characters sequence"
279 (const :tag "ASCII charset" ascii)
280 (repeat character))
281 (cons :tag "Underline characters sequence"
282 (const :tag "Latin-1 charset" latin1)
283 (repeat character))
284 (cons :tag "Underline characters sequence"
285 (const :tag "UTF-8 charset" utf-8)
286 (repeat character))))
288 (defcustom org-e-ascii-bullets '((ascii ?* ?+ ?-)
289 (latin1 ?§ ?¶)
290 (utf-8 ?◊))
291 "Bullet characters for headlines converted to lists in ASCII export.
293 Alist whose key is a symbol among `ascii', `latin1' and `utf-8'
294 and whose value is a list of characters.
296 The first character is used for the first level considered as low
297 level, and so on. If there are more levels than characters given
298 here, the list will be repeated.
300 Note that this variable doesn't affect plain lists
301 representation."
302 :group 'org-export-e-ascii
303 :type '(list
304 (cons :tag "Bullet characters for low level headlines"
305 (const :tag "ASCII charset" ascii)
306 (repeat character))
307 (cons :tag "Bullet characters for low level headlines"
308 (const :tag "Latin-1 charset" latin1)
309 (repeat character))
310 (cons :tag "Bullet characters for low level headlines"
311 (const :tag "UTF-8 charset" utf-8)
312 (repeat character))))
314 (defcustom org-e-ascii-links-to-notes t
315 "Non-nil means convert links to notes before the next headline.
316 When nil, the link will be exported in place. If the line
317 becomes long in this way, it will be wrapped."
318 :group 'org-export-e-ascii
319 :type 'boolean)
321 (defcustom org-e-ascii-table-keep-all-vertical-lines nil
322 "Non-nil means keep all vertical lines in ASCII tables.
323 When nil, vertical lines will be removed except for those needed
324 for column grouping."
325 :group 'org-export-e-ascii
326 :type 'boolean)
328 (defcustom org-e-ascii-table-widen-columns t
329 "Non-nil means widen narrowed columns for export.
330 When nil, narrowed columns will look in ASCII export just like in
331 Org mode, i.e. with \"=>\" as ellipsis."
332 :group 'org-export-e-ascii
333 :type 'boolean)
335 (defcustom org-e-ascii-caption-above nil
336 "When non-nil, place caption string before the element.
337 Otherwise, place it right after it."
338 :group 'org-export-e-ascii
339 :type 'boolean)
341 (defcustom org-e-ascii-verbatim-format "`%s'"
342 "Format string used for verbatim text and inline code."
343 :group 'org-export-e-ascii
344 :type 'string)
346 (defcustom org-e-ascii-format-drawer-function nil
347 "Function called to format a drawer in ASCII.
349 The function must accept two parameters:
350 NAME the drawer name, like \"LOGBOOK\"
351 CONTENTS the contents of the drawer.
352 WIDTH the text width within the drawer.
354 The function should return either the string to be exported or
355 nil to ignore the drawer.
357 For example, the variable could be set to the following function
358 in order to mimic default behaviour:
360 \(defun org-e-ascii-format-drawer-default \(name contents width\)
361 \"Format a drawer element for ASCII export.\"
362 contents\)"
363 :group 'org-export-e-ascii
364 :type 'function)
366 (defcustom org-e-ascii-format-inlinetask-function nil
367 "Function called to format an inlinetask in ASCII.
369 The function must accept six parameters:
370 TODO the todo keyword, as a string
371 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
372 PRIORITY the inlinetask priority, as a string
373 NAME the inlinetask name, as a string.
374 TAGS the inlinetask tags, as a string.
375 CONTENTS the contents of the inlinetask, as a string.
377 The function should return either the string to be exported or
378 nil to ignore the inline task.
380 For example, the variable could be set to the following function
381 in order to mimic default behaviour:
383 \(defun org-e-ascii-format-inlinetask-default
384 \(todo type priority name tags contents\)
385 \"Format an inline task element for ASCII export.\"
386 \(let* \(\(utf8p \(eq \(plist-get info :ascii-charset\) 'utf-8\)\)
387 \(width org-e-ascii-inlinetask-width\)
388 \(org-e-ascii--indent-string
389 \(concat
390 ;; Top line, with an additional blank line if not in UTF-8.
391 \(make-string width \(if utf8p ?━ ?_\)\) \"\\n\"
392 \(unless utf8p \(concat \(make-string width ? \) \"\\n\"\)\)
393 ;; Add title. Fill it if wider than inlinetask.
394 \(let \(\(title \(org-e-ascii--build-title inlinetask info width\)\)\)
395 \(if \(<= \(length title\) width\) title
396 \(org-e-ascii--fill-string title width info\)\)\)
397 \"\\n\"
398 ;; If CONTENTS is not empty, insert it along with
399 ;; a separator.
400 \(when \(org-string-nw-p contents\)
401 \(concat \(make-string width \(if utf8p ?─ ?-\)\) \"\\n\" contents\)\)
402 ;; Bottom line.
403 \(make-string width \(if utf8p ?━ ?_\)\)\)
404 ;; Flush the inlinetask to the right.
405 \(- \(plist-get info :ascii-width\)
406 \(plist-get info :ascii-margin\)
407 \(plist-get info :ascii-inner-margin\)
408 \(org-e-ascii--current-text-width inlinetask info\)\)"
409 :group 'org-export-e-ascii
410 :type 'function)
414 ;;; Internal Functions
416 ;; Internal functions fall into three categories.
418 ;; The first one is about text formatting. The core function is
419 ;; `org-e-ascii--current-text-width', which determines the current
420 ;; text width allowed to a given element. In other words, it helps
421 ;; keeping each line width within maximum text width defined in
422 ;; `org-e-ascii-text-width'. Once this information is known,
423 ;; `org-e-ascii--fill-string', `org-e-ascii--justify-string',
424 ;; `org-e-ascii--box-string' and `org-e-ascii--indent-string' can
425 ;; operate on a given output string.
427 ;; The second category contains functions handling elements listings,
428 ;; triggered by "#+TOC:" keyword. As such, `org-e-ascii--build-toc'
429 ;; returns a complete table of contents, `org-e-ascii--list-listings'
430 ;; returns a list of referenceable src-block elements, and
431 ;; `org-e-ascii--list-tables' does the same for table elements.
433 ;; The third category includes general helper functions.
434 ;; `org-e-ascii--build-title' creates the title for a given headline
435 ;; or inlinetask element. `org-e-ascii--build-caption' returns the
436 ;; caption string associated to a table or a src-block.
437 ;; `org-e-ascii--describe-links' creates notes about links for
438 ;; insertion at the end of a section. It uses
439 ;; `org-e-ascii--unique-links' to get the list of links to describe.
440 ;; Eventually, `org-e-ascii--translate' reads `org-e-ascii-dictionary'
441 ;; to internationalize output.
444 (defun org-e-ascii--fill-string (s text-width info &optional justify)
445 "Fill a string with specified text-width and return it.
447 S is the string being filled. TEXT-WIDTH is an integer
448 specifying maximum length of a line. INFO is the plist used as
449 a communication channel.
451 Optional argument JUSTIFY can specify any type of justification
452 among `left', `center', `right' or `full'. A nil value is
453 equivalent to `left'. For a justification that doesn't also fill
454 string, see `org-e-ascii--justify-string'.
456 Return nil if S isn't a string."
457 ;; Don't fill paragraph when break should be preserved.
458 (cond ((not (stringp s)) nil)
459 ((plist-get info :preserve-breaks) s)
460 (t (with-temp-buffer
461 (let ((fill-column text-width)
462 (use-hard-newlines t))
463 (insert s)
464 (fill-region (point-min) (point-max) justify))
465 (buffer-string)))))
467 (defun org-e-ascii--justify-string (s text-width how)
468 "Justify string S.
469 TEXT-WIDTH is an integer specifying maximum length of a line.
470 HOW determines the type of justification: it can be `left',
471 `right', `full' or `center'."
472 (with-temp-buffer
473 (insert s)
474 (goto-char (point-min))
475 (let ((fill-column text-width))
476 (while (< (point) (point-max))
477 (justify-current-line how)
478 (forward-line)))
479 (buffer-string)))
481 (defun org-e-ascii--indent-string (s width)
482 "Indent string S by WIDTH white spaces.
483 Empty lines are not indented."
484 (when (stringp s)
485 (replace-regexp-in-string
486 "\\(^\\)\\(?:.*\\S-\\)" (make-string width ? ) s nil nil 1)))
488 (defun org-e-ascii--box-string (s info)
489 "Return string S with a partial box to its left.
490 INFO is a plist used as a communicaton channel."
491 (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
492 (format (if utf8p "╭────\n%s\n╰────" ",----\n%s\n`----")
493 (replace-regexp-in-string
494 "^" (if utf8p "│ " "| ")
495 ;; Remove last newline character.
496 (replace-regexp-in-string "\n[ \t]*\\'" "" s)))))
498 (defun org-e-ascii--current-text-width (element info)
499 "Return maximum text width for ELEMENT's contents.
500 INFO is a plist used as a communication channel."
501 (cond
502 ;; Elements with an absolute width: `headline' and `inlinetask'.
503 ((eq (car element) 'inlinetask) org-e-ascii-inlinetask-width)
504 ((eq (car element) 'headline)
505 (- org-e-ascii-text-width
506 (let ((low-level-rank (org-export-low-level-p element info)))
507 (if low-level-rank (* low-level-rank 2) org-e-ascii-global-margin))))
508 ;; Elements with a relative width: store maximum text width in
509 ;; TOTAL-WIDTH.
511 (let* ((genealogy (cons element (plist-get info :genealogy)))
512 ;; Total width is determined by the presence, or not, of an
513 ;; inline task among ELEMENT parents.
514 (total-width
515 (if (loop for parent in genealogy
516 thereis (eq (car parent) 'inlinetask))
517 org-e-ascii-inlinetask-width
518 ;; No inlinetask: Remove global margin from text width.
519 (- org-e-ascii-text-width
520 org-e-ascii-global-margin
521 (let ((parent (org-export-get-parent-headline element info)))
522 ;; Inner margin doesn't apply to text before first
523 ;; headline.
524 (if (not parent) 0
525 (let ((low-level-rank
526 (org-export-low-level-p parent info)))
527 ;; Inner margin doesn't apply to contents of
528 ;; low level headlines, since they've got their
529 ;; own indentation mechanism.
530 (if low-level-rank (* low-level-rank 2)
531 org-e-ascii-inner-margin))))))))
532 (- total-width
533 ;; Each `quote-block', `quote-section' and `verse-block' above
534 ;; narrows text width by twice the standard margin size.
535 (+ (* (loop for parent in genealogy
536 when (memq (car parent)
537 '(quote-block quote-section verse-block))
538 count parent)
539 2 org-e-ascii-quote-margin)
540 ;; Text width within a plain-list is restricted by
541 ;; indentation of current item. If that's the case,
542 ;; compute it with the help of `:structure' property from
543 ;; parent item, if any.
544 (let ((parent-item
545 (if (eq (car element) 'item) element
546 (loop for parent in genealogy
547 when (eq (car parent) 'item)
548 return parent))))
549 (if (not parent-item) 0
550 ;; Compute indentation offset of the current item,
551 ;; that is the sum of the difference between its
552 ;; indentation and the indentation of the top item in
553 ;; the list and current item bullet's length. Also
554 ;; remove tag length (for description lists) or bullet
555 ;; length.
556 (let ((struct (org-element-get-property :structure parent-item))
557 (beg-item (org-element-get-property :begin parent-item)))
558 (+ (- (org-list-get-ind beg-item struct)
559 (org-list-get-ind
560 (org-list-get-top-point struct) struct))
561 (length
562 (or (org-list-get-tag beg-item struct)
563 (org-list-get-bullet beg-item struct)))))))))))))
565 (defun org-e-ascii--build-title
566 (element info text-width &optional underline notags)
567 "Format ELEMENT title and return it.
569 ELEMENT is either an `headline' or `inlinetask' element. INFO is
570 a plist used as a communication channel. TEXT-WIDTH is an
571 integer representing the maximum length of a line.
573 When optional argument UNDERLINE is non-nil, underline title,
574 without the tags, according to `org-e-ascii-underline'
575 specifications.
577 if optional argument NOTAGS is nil, no tags will be added to the
578 title."
579 (let* ((headlinep (eq (car element) 'headline))
580 (numbers
581 ;; Numbering is specific to headlines.
582 (and headlinep
583 ;; Section numbering must be active, and headline's
584 ;; level should be above specified limit, if any.
585 (let ((sec-num (plist-get info :section-numbers)))
586 (if (not (wholenump sec-num)) sec-num
587 (<= (org-export-get-relative-level headline info) sec-num)))
588 ;; All tests passed: build numbering string.
589 (concat
590 (mapconcat
591 #'number-to-string
592 (org-export-get-headline-number element info) ".")
593 " ")))
594 (text (org-export-secondary-string
595 (org-element-get-property :title element) 'e-ascii info))
596 (todo
597 (and (plist-get info :with-todo-keywords)
598 (let ((todo (org-element-get-property :todo-keyword element)))
599 (and todo
600 (concat (org-export-secondary-string todo 'e-ascii info)
601 " ")))))
602 (tags (and (not notags)
603 (plist-get info :with-tags)
604 (org-element-get-property :tags element)))
605 (priority
606 (and (plist-get info :with-priority)
607 (concat (org-element-get-property :priority element) " ")))
608 (first-part (concat numbers todo priority text)))
609 (concat
610 first-part
611 ;; Align tags, if any.
612 (when tags
613 (format
614 (format " %%%ds"
615 (max (- text-width (1+ (length first-part))) (length tags)))
616 tags))
617 ;; Maybe underline text, if ELEMENT type is `headline' and an
618 ;; underline character has been defined.
619 (when (and underline headlinep)
620 (let ((under-char
621 (nth (1- (org-export-get-relative-level element info))
622 (cdr (assq (plist-get info :ascii-charset)
623 org-e-ascii-underline)))))
624 (and under-char
625 (concat "\n"
626 (make-string (length first-part) under-char))))))))
628 (defun org-e-ascii--build-caption (element info)
629 "Return caption string for ELEMENT, if applicable.
631 INFO is a plist used as a communication channel.
633 The caption string contains the sequence number of ELEMENT if it
634 has a name affiliated keyword, along with the real caption, if
635 any. Return nil when ELEMENT has no affiliated caption or name
636 keyword."
637 (let ((caption (org-element-get-property :caption element))
638 (name (org-element-get-property :name element)))
639 (when (or caption name)
640 ;; Get sequence number of current src-block among every
641 ;; src-block with either a caption or a name.
642 (let ((reference
643 (org-export-get-ordinal
644 element info nil nil
645 (lambda (el) (or (org-element-get-property :caption el)
646 (org-element-get-property :name el)))))
647 (title-fmt (org-e-ascii--translate
648 (case (car element)
649 (table "Table %d: %s")
650 (src-block "Listing %d: %s")) info)))
651 (org-e-ascii--fill-string
652 (format
653 title-fmt reference
654 (if (not caption) name
655 (org-export-secondary-string (car caption) 'e-ascii info)))
656 (org-e-ascii--current-text-width element info) info)))))
658 (defun org-e-ascii--build-toc (info &optional n keyword)
659 "Return a table of contents.
661 INFO is a plist used as a communication channel.
663 Optional argument N, when non-nil, is an integer specifying the
664 depth of the table.
666 Optional argument KEYWORD specifies the TOC keyword, if any, from
667 which the table of contents generation has been initiated."
668 (let ((title (org-e-ascii--translate "Table Of Contents\n" info)))
669 (concat
670 title
671 (make-string (1- (length title))
672 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
673 "\n\n"
674 (let ((text-width
675 (if keyword (org-e-ascii--current-text-width keyword info)
676 (- org-e-ascii-text-width org-e-ascii-global-margin))))
677 (mapconcat
678 (lambda (headline)
679 (let* ((level (org-export-get-relative-level headline info))
680 (indent (* (1- level) 3)))
681 (concat
682 (unless (zerop indent) (concat (make-string (1- indent) ?.) " "))
683 (org-e-ascii--build-title
684 headline info (- text-width indent) nil
685 (eq (plist-get info :with-tags) 'not-in-toc)))))
686 (org-export-collect-headlines info n) "\n")))))
688 (defun org-e-ascii--list-listings (keyword info)
689 "Return a list of listings.
691 KEYWORD is the keyword that initiated the list of listings
692 generation. INFO is a plist used as a communication channel."
693 (let ((title (org-e-ascii--translate "List Of Listings\n" info)))
694 (concat
695 title
696 (make-string (1- (length title))
697 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
698 "\n\n"
699 (let ((text-width
700 (if keyword (org-e-ascii--current-text-width keyword info)
701 (- org-e-ascii-text-width org-e-ascii-global-margin)))
702 ;; Use a counter instead of retreiving ordinal of each
703 ;; src-block.
704 (count 0))
705 (mapconcat
706 (lambda (src-block)
707 ;; Store initial text so its length can be computed. This is
708 ;; used to properly align caption right to it in case of
709 ;; filling (like contents of a description list item).
710 (let ((initial-text
711 (format (org-e-ascii--translate "Listing %d: " info)
712 (incf count))))
713 (concat
714 initial-text
715 (org-trim
716 (org-e-ascii--indent-string
717 (org-e-ascii--fill-string
718 (let ((caption (org-element-get-property :caption src-block)))
719 (if (not caption) (org-element-get-property :name src-block)
720 (org-export-secondary-string
721 ;; Use short name in priority, if available.
722 (or (cdr caption) (car caption)) 'e-ascii info)))
723 (- text-width (length initial-text)) info)
724 (length initial-text))))))
725 (org-export-collect-listings info) "\n")))))
727 (defun org-e-ascii--list-tables (keyword info)
728 "Return a list of listings.
730 KEYWORD is the keyword that initiated the list of listings
731 generation. INFO is a plist used as a communication channel."
732 (let ((title (org-e-ascii--translate "List Of Tables\n" info)))
733 (concat
734 title
735 (make-string (1- (length title))
736 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
737 "\n\n"
738 (let ((text-width
739 (if keyword (org-e-ascii--current-text-width keyword info)
740 (- org-e-ascii-text-width org-e-ascii-global-margin)))
741 ;; Use a counter instead of retreiving ordinal of each
742 ;; src-block.
743 (count 0))
744 (mapconcat
745 (lambda (table)
746 ;; Store initial text so its length can be computed. This is
747 ;; used to properly align caption right to it in case of
748 ;; filling (like contents of a description list item).
749 (let ((initial-text
750 (format (org-e-ascii--translate "Table %d: " info)
751 (incf count))))
752 (concat
753 initial-text
754 (org-trim
755 (org-e-ascii--indent-string
756 (org-e-ascii--fill-string
757 (let ((caption (org-element-get-property :caption table)))
758 (if (not caption) (org-element-get-property :name table)
759 ;; Use short name in priority, if available.
760 (org-export-secondary-string
761 (or (cdr caption) (car caption)) 'e-ascii info)))
762 (- text-width (length initial-text)) info)
763 (length initial-text))))))
764 (org-export-collect-tables info) "\n")))))
766 (defun org-e-ascii--unique-links (element info)
767 "Return a list of unique link references in ELEMENT.
769 ELEMENT is either an headline element or a section element. INFO
770 is a plist used as a communication channel.
772 It covers links that may be found current headline's title, in
773 the following section and in any inlinetask's title there."
774 (let* (seen
775 (unique-link-p
776 (function
777 ;; Return LINK if it wasn't referenced so far, or nil.
778 ;; Update SEEN links along the way.
779 (lambda (link)
780 (let ((footprint
781 (cons (org-element-get-property :raw-link link)
782 (org-element-get-contents link))))
783 (unless (member footprint seen)
784 (push footprint seen) link)))))
785 (harvest-links-in-title
786 (function
787 ;; Return a list of all unique links in ELEMENT. ELEMENT
788 ;; may be an headline or an inlinetask element.
789 (lambda (element)
790 (let (acc)
791 (dolist (obj (org-element-get-property :title element) acc)
792 (when (and (listp obj) (eq (car obj) 'link))
793 (let ((link (funcall unique-link-p obj)))
794 (and link (push link acc)))))))))
795 ;; Retrieve headline's section, if it exists.
796 (section (if (eq (car element) 'section) element
797 (let ((sec (car (org-element-get-contents element))))
798 (and (eq (car sec) 'section) sec))))
799 (headline (if (eq (car element) 'headline) element
800 (org-export-get-parent-headline element info))))
801 (append
802 ;; Links that may be in HEADLINE's title.
803 (funcall harvest-links-in-title headline)
804 ;; Get all links in SECTION.
805 (org-element-map
806 section 'link (lambda (link local) (funcall unique-link-p link)) info)
807 ;; Links that may be in inlinetasks titles within SECTION.
808 (let (acc)
809 (org-element-map
810 section 'inlinetask
811 (lambda (inlinetask local)
812 (push (funcall harvest-links-in-title inlinetask) acc))
813 info)
814 (delq nil acc)))))
816 (defun org-e-ascii--describe-links (links width info)
817 "Return a string describing a list of links.
819 LINKS is a list of link type objects, as returned by
820 `org-e-ascii--unique-links'. WIDTH is the text width allowed for
821 the output string. INFO is a plist used as a communication
822 channel."
823 (mapconcat
824 (lambda (link)
825 (let ((type (org-element-get-property :type link))
826 (anchor (let ((desc (org-element-get-contents link)))
827 (if (not desc)
828 (org-element-get-property :raw-link link)
829 (org-export-secondary-string desc 'e-ascii info)))))
830 (cond
831 ;; Coderefs and radio links are ignored.
832 ((member type '("coderef" "radio")) nil)
833 ;; Id, custom-id and fuzzy links (with the exception of
834 ;; targets): Headlines refer to their numbering.
835 ((member type '("custom-id" "fuzzy" "id"))
836 (let ((destination (if (string= type "fuzzy")
837 (org-export-resolve-fuzzy-link link info)
838 (org-export-resolve-id-link link info))))
839 (unless (eq (car destination) 'target)
840 (concat
841 (org-e-ascii--fill-string
842 (format
843 "[%s] %s"
844 anchor
845 (if (not destination)
846 (org-e-ascii--translate "Unknown reference" info)
847 (format
848 (org-e-ascii--translate "See section %s" info)
849 (mapconcat 'number-to-string
850 (org-export-get-headline-number destination info)
851 "."))))
852 width info) "\n\n"))))
853 ;; Do not add a link that cannot be resolved and doesn't have
854 ;; any description: destination is already visible in the
855 ;; paragraph.
856 ((not (org-element-get-contents link)) nil)
858 (concat
859 (org-e-ascii--fill-string
860 (format "[%s] %s" anchor (org-element-get-property :raw-link link))
861 width info)
862 "\n\n")))))
863 links ""))
867 ;;; Template
869 (defun org-e-ascii-template--document-title (info)
870 "Return document title, as a string.
871 INFO is a plist used as a communication channel."
872 (let ((text-width org-e-ascii-text-width)
873 (title (org-export-secondary-string
874 (plist-get info :title) 'e-ascii info))
875 (author
876 (and (plist-get info :with-author)
877 (let ((auth (plist-get info :author)))
878 (and auth (org-export-secondary-string auth 'e-ascii info)))))
879 (email
880 (and (plist-get info :with-email)
881 (org-export-secondary-string
882 (plist-get info :email) 'e-ascii info)))
883 (date (plist-get info :date)))
884 ;; There are two types of title blocks depending on the presence
885 ;; of a title to display.
886 (if (string= title "")
887 ;; Title block without a title. DATE is positioned at the top
888 ;; right of the document, AUTHOR to the top left and EMAIL
889 ;; just below.
890 (cond
891 ((and (org-string-nw-p date) (org-string-nw-p author))
892 (concat
893 author
894 (make-string (- text-width (length date) (length author)) ? )
895 date
896 (when (org-string-nw-p email) (concat "\n" email))
897 "\n\n\n"))
898 ((and (org-string-nw-p date) (org-string-nw-p email))
899 (concat
900 email
901 (make-string (- text-width (length date) (length email)) ? )
902 date "\n\n\n"))
903 ((org-string-nw-p date)
904 (concat
905 (org-e-ascii--justify-string date text-width 'right)
906 "\n\n\n"))
907 ((and (org-string-nw-p author) (org-string-nw-p email))
908 (concat author "\n" email "\n\n\n"))
909 ((org-string-nw-p author) (concat author "\n\n\n"))
910 ((org-string-nw-p email) (concat email "\n\n\n")))
911 ;; Title block with a title. Document's TITLE, along with the
912 ;; AUTHOR and its EMAIL are both overlined and an underlined,
913 ;; centered. Date is just below, also centered.
914 (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
915 ;; Format TITLE. It may be filled if it is too wide,
916 ;; that is wider than the two thirds of the total width.
917 (title-len (min (length title) (/ (* 2 text-width) 3)))
918 (formatted-title (org-e-ascii--fill-string title title-len info))
919 (line
920 (make-string
921 (min (+ (max title-len (length author) (length email)) 2)
922 text-width) (if utf8p ?━ ?_))))
923 (org-e-ascii--justify-string
924 (concat line "\n"
925 (unless utf8p "\n")
926 (upcase formatted-title)
927 (if utf8p "\n\n\n" "\n\n")
928 (cond
929 ((and (org-string-nw-p author) (org-string-nw-p email))
930 (concat author "\n" email))
931 ((org-string-nw-p author) author)
932 ((org-string-nw-p email) email))
933 "\n" line
934 (when (org-string-nw-p date) (concat "\n\n\n" date))
935 "\n\n\n") text-width 'center)))))
937 (defun org-e-ascii-template (contents info)
938 "Return complete document string after ASCII conversion.
939 CONTENTS is the transcoded contents string. INFO is a plist
940 holding export options."
941 (org-e-ascii--indent-string
942 (let ((text-width (- org-e-ascii-text-width org-e-ascii-global-margin)))
943 ;; 1. Build title block.
944 (concat
945 (org-e-ascii-template--document-title info)
946 ;; 2. Table of contents.
947 (let ((depth (plist-get info :with-toc)))
948 (when depth
949 (concat
950 (org-e-ascii--build-toc info (and (wholenump depth) depth))
951 "\n\n\n")))
952 ;; 3. Document's body.
953 contents
954 ;; 4. Footnote definitions.
955 (let ((definitions (org-export-collect-footnote-definitions
956 (plist-get info :parse-tree) info))
957 ;; Insert full links right inside the footnote definition
958 ;; as they have no chance to be inserted later.
959 (org-e-ascii-links-to-notes nil))
960 (when definitions
961 (concat
962 "\n\n\n"
963 (let ((title (org-e-ascii--translate "Footnotes\n" info)))
964 (concat
965 title
966 (make-string
967 (1- (length title))
968 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))))
969 "\n\n"
970 (mapconcat
971 (lambda (ref)
972 (let ((id (format "[%s] " (car ref))))
973 ;; Distinguish between inline definitions and
974 ;; full-fledged definitions.
975 (org-trim
976 (let ((def (nth 2 ref)))
977 (if (eq (car def) 'org-data)
978 ;; Full-fledged definition: footnote ID is
979 ;; inserted inside the first parsed paragraph
980 ;; (FIRST), if any, to be sure filling will
981 ;; take it into consideration.
982 (let ((first (car (org-element-get-contents def))))
983 (if (not (eq (car first) 'paragraph))
984 (concat id "\n" (org-export-data def 'e-ascii info))
985 (push id (nthcdr 2 first))
986 (org-export-data def 'e-ascii info)))
987 ;; Fill paragraph once footnote ID is inserted in
988 ;; order to have a correct length for first line.
989 (org-e-ascii--fill-string
990 (concat id (org-export-secondary-string def 'e-ascii info))
991 text-width info))))))
992 definitions "\n\n"))))
993 ;; 5. Creator. Ignore `comment' value as there are no comments in
994 ;; ASCII. Justify it to the bottom right.
995 (let ((creator-info (plist-get info :with-creator)))
996 (unless (or (not creator-info) (eq creator-info 'comment))
997 (concat
998 "\n\n\n"
999 (org-e-ascii--fill-string
1000 (plist-get info :creator) text-width info 'right))))))
1001 org-e-ascii-global-margin))
1003 (defun org-e-ascii--translate (s info)
1004 "Translate string S.
1006 INFO is a plist used as a communication channel.
1008 Translation depends on `:language' property and allowed charset.
1009 If no translation in found for a given language and a given
1010 charset, fall-back to S."
1011 (let* ((charset (intern (format ":%s" (plist-get info :ascii-charset))))
1012 (lang (plist-get info :language))
1013 (translations (cdr (assoc s org-e-ascii-dictionary))))
1014 (or (plist-get (cdr (assoc lang translations)) charset) s)))
1018 ;;; Transcode Functions
1020 ;;;; Babel Call
1022 ;; Babel Calls are ignored.
1025 ;;;; Center Block
1027 (defun org-e-ascii-center-block (center-block contents info)
1028 "Transcode a CENTER-BLOCK element from Org to ASCII.
1029 CONTENTS holds the contents of the block. INFO is a plist
1030 holding contextual information."
1031 (org-e-ascii--justify-string
1032 contents (org-e-ascii--current-text-width center-block info) 'center))
1035 ;;;; Comment
1037 ;; Comments are ignored.
1040 ;;;; Comment Block
1042 ;; Comment Blocks are ignored.
1045 ;;;; Drawer
1047 (defun org-e-ascii-drawer (drawer contents info)
1048 "Transcode a DRAWER element from Org to ASCII.
1049 CONTENTS holds the contents of the block. INFO is a plist
1050 holding contextual information."
1051 (let ((name (org-element-get-property :drawer-name drawer))
1052 (width (org-e-ascii--current-text-width drawer info)))
1053 (if (functionp org-e-ascii-format-drawer-function)
1054 (funcall org-e-ascii-format-drawer-function name contents width)
1055 ;; If there's no user defined function: simply
1056 ;; display contents of the drawer.
1057 contents)))
1060 ;;;; Dynamic Block
1062 (defun org-e-ascii-dynamic-block (dynamic-block contents info)
1063 "Transcode a DYNAMIC-BLOCK element from Org to ASCII.
1064 CONTENTS holds the contents of the block. INFO is a plist
1065 holding contextual information. See
1066 `org-export-data'."
1067 contents)
1070 ;;;; Emphasis
1072 (defun org-e-ascii-emphasis (emphasis contents info)
1073 "Transcode EMPHASIS from Org to ASCII.
1074 CONTENTS is the contents of the emphasized text. INFO is a plist
1075 holding contextual information.."
1076 (let ((marker (org-element-get-property :marker emphasis)))
1077 ;; Leave emphasis markers as-is.
1078 (concat marker contents marker)))
1081 ;;;; Entity
1083 (defun org-e-ascii-entity (entity contents info)
1084 "Transcode an ENTITY object from Org to ASCII.
1085 CONTENTS are the definition itself. INFO is a plist holding
1086 contextual information."
1087 (org-element-get-property
1088 (intern (concat ":" (symbol-name (plist-get info :ascii-charset))))
1089 entity))
1092 ;;;; Example Block
1094 (defun org-e-ascii-example-block (example-block contents info)
1095 "Transcode a EXAMPLE-BLOCK element from Org to ASCII.
1096 CONTENTS is nil. INFO is a plist holding contextual information."
1097 (org-e-ascii--box-string (org-export-handle-code example-block info) info))
1100 ;;;; Export Snippet
1102 (defun org-e-ascii-export-snippet (export-snippet contents info)
1103 "Transcode a EXPORT-SNIPPET object from Org to ASCII.
1104 CONTENTS is nil. INFO is a plist holding contextual information."
1105 (org-element-get-property :value export-snippet))
1108 ;;;; Export Block
1110 (defun org-e-ascii-export-block (export-block contents info)
1111 "Transcode a EXPORT-BLOCK element from Org to ASCII.
1112 CONTENTS is nil. INFO is a plist holding contextual information."
1113 (when (string= (org-element-get-property :type export-block) "ascii")
1114 (org-remove-indentation (org-element-get-property :value export-block))))
1117 ;;;; Fixed Width
1119 (defun org-e-ascii-fixed-width (fixed-width contents info)
1120 "Transcode a FIXED-WIDTH element from Org to ASCII.
1121 CONTENTS is nil. INFO is a plist holding contextual information."
1122 (org-e-ascii--box-string
1123 (replace-regexp-in-string
1124 "^[ \t]*: ?" "" (org-element-get-property :value fixed-width)) info))
1127 ;;;; Footnote Definition
1129 ;; Footnote Definitions are ignored. They are compiled at the end of
1130 ;; the document, by `org-e-ascii-template'.
1133 ;;;; Footnote Reference
1135 (defun org-e-ascii-footnote-reference (footnote-reference contents info)
1136 "Transcode a FOOTNOTE-REFERENCE element from Org to ASCII.
1137 CONTENTS is nil. INFO is a plist holding contextual information."
1138 (format "[%s]" (org-export-get-footnote-number footnote-reference info)))
1141 ;;;; Headline
1143 (defun org-e-ascii-headline (headline contents info)
1144 "Transcode an HEADLINE element from Org to ASCII.
1145 CONTENTS holds the contents of the headline. INFO is a plist
1146 holding contextual information."
1147 ;; Don't export footnote section, which will be handled at the end
1148 ;; of the template.
1149 (unless (org-element-get-property :footnote-section-p headline)
1150 (let* ((low-level-rank (org-export-low-level-p headline info))
1151 (width (org-e-ascii--current-text-width headline info))
1152 ;; Blank lines between headline and its contents.
1153 ;; `org-e-ascii-headline-spacing', when set, overwrites
1154 ;; original buffer's spacing.
1155 (pre-blanks
1156 (make-string
1157 (if org-e-ascii-headline-spacing (car org-e-ascii-headline-spacing)
1158 (org-element-get-property :pre-blank headline)) ?\n))
1159 ;; Even if HEADLINE has no section, there might be some
1160 ;; links in its title that we shouldn't forget to describe.
1161 (links
1162 (unless (eq (caar (org-element-get-contents headline)) 'section)
1163 (org-e-ascii--describe-links
1164 (org-e-ascii--unique-links headline info) width info))))
1165 ;; Deep subtree: export it as a list item.
1166 (if low-level-rank
1167 (concat
1168 ;; Bullet.
1169 (let ((bullets (cdr (assq (plist-get info :ascii-charset)
1170 org-e-ascii-bullets))))
1171 (char-to-string
1172 (nth (mod (1- low-level-rank) (length bullets)) bullets)))
1174 ;; Title.
1175 (org-e-ascii--build-title headline info width) "\n"
1176 ;; Contents, indented by length of bullet.
1177 pre-blanks
1178 (org-e-ascii--indent-string
1179 (concat contents
1180 (when (org-string-nw-p links) (concat "\n\n" links)))
1182 ;; Else: Standard headline.
1183 (concat
1184 (org-e-ascii--build-title headline info width 'underline)
1185 "\n" pre-blanks
1186 (concat (when (org-string-nw-p links) links) contents))))))
1189 ;;;; Horizontal Rule
1191 (defun org-e-ascii-horizontal-rule (horizontal-rule contents info)
1192 "Transcode an HORIZONTAL-RULE object from Org to ASCII.
1193 CONTENTS is nil. INFO is a plist holding contextual
1194 information."
1195 (let ((attr
1196 (read
1197 (format
1198 "(%s)"
1199 (mapconcat
1200 #'identity
1201 (org-element-get-property :attr_ascii horizontal-rule)
1202 " ")))))
1203 (make-string (or (and (wholenump (plist-get attr :width))
1204 (plist-get attr :width))
1205 (org-e-ascii--current-text-width horizontal-rule info))
1206 (if (eq (plist-get info :ascii-charset) 'utf-8) ?― ?-))))
1209 ;;;; Inline Babel Call
1211 ;; Inline Babel Calls are ignored.
1214 ;;;; Inline Src Block
1216 (defun org-e-ascii-inline-src-block (inline-src-block contents info)
1217 "Transcode an INLINE-SRC-BLOCK element from Org to ASCII.
1218 CONTENTS holds the contents of the item. INFO is a plist holding
1219 contextual information."
1220 (format org-e-ascii-verbatim-format
1221 (org-element-get-property :value inline-src-block)))
1224 ;;;; Inlinetask
1226 (defun org-e-ascii-inlinetask (inlinetask contents info)
1227 "Transcode an INLINETASK element from Org to ASCII.
1228 CONTENTS holds the contents of the block. INFO is a plist
1229 holding contextual information."
1230 (let ((width (org-e-ascii--current-text-width inlinetask info))
1231 (title (org-export-secondary-string
1232 (org-element-get-property :title inlinetask) 'e-ascii info))
1233 (todo (and (plist-get info :with-todo-keywords)
1234 (let ((todo (org-element-get-property
1235 :todo-keyword inlinetask)))
1236 (and todo
1237 (org-export-secondary-string todo 'e-ascii info)))))
1238 (todo-type (org-element-get-property :todo-type inlinetask))
1239 (tags (and (plist-get info :with-tags)
1240 (org-element-get-property :tags inlinetask)))
1241 (priority (and (plist-get info :with-priority)
1242 (org-element-get-property :priority inlinetask))))
1243 ;; If `org-e-ascii-format-inlinetask-function' is provided, call it
1244 ;; with appropriate arguments.
1245 (if (functionp org-e-ascii-format-inlinetask-function)
1246 (funcall org-e-ascii-format-inlinetask-function
1247 todo todo-type priority title tags contents width)
1248 ;; Otherwise, use a default template.
1249 (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
1250 (org-e-ascii--indent-string
1251 (concat
1252 ;; Top line, with an additional blank line if not in UTF-8.
1253 (make-string width (if utf8p ?━ ?_)) "\n"
1254 (unless utf8p (concat (make-string width ? ) "\n"))
1255 ;; Add title. Fill it if wider than inlinetask.
1256 (let ((title (org-e-ascii--build-title inlinetask info width)))
1257 (if (<= (length title) width) title
1258 (org-e-ascii--fill-string title width info)))
1259 "\n"
1260 ;; If CONTENTS is not empty, insert it along with
1261 ;; a separator.
1262 (when (org-string-nw-p contents)
1263 (concat (make-string width (if utf8p ?─ ?-)) "\n" contents))
1264 ;; Bottom line.
1265 (make-string width (if utf8p ?━ ?_)))
1266 ;; Flush the inlinetask to the right.
1267 (- org-e-ascii-text-width org-e-ascii-global-margin
1268 (if (not (org-export-get-parent-headline inlinetask info)) 0
1269 org-e-ascii-inner-margin)
1270 (org-e-ascii--current-text-width inlinetask info)))))))
1273 ;;;; Item
1275 (defun org-e-ascii-item (item contents info)
1276 "Transcode an ITEM element from Org to ASCII.
1277 CONTENTS holds the contents of the item. INFO is a plist holding
1278 contextual information."
1279 (let ((bullet
1280 ;; First parent of ITEM is always the plain-list. Get
1281 ;; `:type' property from it.
1282 (let ((type (org-element-get-property
1283 :type (car (plist-get info :genealogy)))))
1284 (if (eq type 'descriptive)
1285 (concat
1286 (org-export-secondary-string
1287 (org-element-get-property :tag item) 'e-ascii info) ": ")
1288 (org-element-get-property :bullet item)))))
1289 (concat
1290 ;; Change bullets into more visible form if UTF-8 is active.
1291 (if (not (eq (plist-get info :ascii-charset) 'utf-8)) bullet
1292 (replace-regexp-in-string
1293 "-" "•"
1294 (replace-regexp-in-string
1295 "+" "⁃"
1296 (replace-regexp-in-string
1297 "*" "‣" bullet))))
1298 ;; Contents: Pay attention to indentation. Note: check-boxes are
1299 ;; already taken care of at the paragraph level so they don't
1300 ;; interfere with indentation.
1301 (let ((contents (org-e-ascii--indent-string contents (length bullet))))
1302 (if (eq (caar (org-element-get-contents item)) 'paragraph)
1303 (org-trim contents)
1304 (concat "\n" contents))))))
1307 ;;;; Keyword
1309 (defun org-e-ascii-keyword (keyword contents info)
1310 "Transcode a KEYWORD element from Org to ASCII.
1311 CONTENTS is nil. INFO is a plist holding contextual
1312 information."
1313 (let ((key (downcase (org-element-get-property :key keyword)))
1314 (value (org-element-get-property :value keyword)))
1315 (cond
1316 ((string= key "ascii") value)
1317 ((string= key "toc")
1318 (let ((value (downcase value)))
1319 (cond
1320 ((string-match "\\<headlines\\>" value)
1321 (let ((depth (or (and (string-match "[0-9]+" value)
1322 (string-to-number (match-string 0 value)))
1323 (plist-get info :with-toc))))
1324 (org-e-ascii--build-toc
1325 info (and (wholenump depth) depth) keyword)))
1326 ((string= "tables" value)
1327 (org-e-ascii--list-tables keyword info))
1328 ((string= "listings" value)
1329 (org-e-ascii--list-listings keyword info)))))
1330 ((string= key "include")
1331 (org-export-included-file keyword 'e-ascii info)))))
1334 ;;;; Latex Environment
1336 (defun org-e-ascii-latex-environment (latex-environment contents info)
1337 "Transcode a LATEX-ENVIRONMENT element from Org to ASCII.
1338 CONTENTS is nil. INFO is a plist holding contextual
1339 information."
1340 (org-remove-indentation (org-element-get-property :value latex-environment)))
1343 ;;;; Latex Fragment
1345 (defun org-e-ascii-latex-fragment (latex-fragment contents info)
1346 "Transcode a LATEX-FRAGMENT object from Org to ASCII.
1347 CONTENTS is nil. INFO is a plist holding contextual
1348 information."
1349 (org-element-get-property :value latex-fragment))
1352 ;;;; Line Break
1354 (defun org-e-ascii-line-break (line-break contents info)
1355 "Transcode a LINE-BREAK object from Org to ASCII.
1356 CONTENTS is nil. INFO is a plist holding contextual
1357 information." hard-newline)
1360 ;;;; Link
1362 (defun org-e-ascii-link (link desc info)
1363 "Transcode a LINK object from Org to ASCII.
1365 DESC is the description part of the link, or the empty string.
1366 INFO is a plist holding contextual information."
1367 (let ((raw-link (org-element-get-property :raw-link link))
1368 (type (org-element-get-property :type link)))
1369 (cond
1370 ((string= type "coderef")
1371 (let ((ref (org-element-get-property :path link)))
1372 (format (org-export-get-coderef-format ref desc)
1373 (org-export-resolve-coderef ref info))))
1374 ;; Do not apply a special syntax on radio links.
1375 ((string= type "radio") desc)
1376 ;; Do not apply a special syntax on fuzzy links pointing to
1377 ;; targets.
1378 ((and (string= type "fuzzy")
1379 (let ((path (org-element-get-property :path link)))
1380 (loop for target in (plist-get info :target-list)
1381 thereis (string=
1382 (org-element-get-property :raw-value target)
1383 path))))
1384 (if (org-string-nw-p desc) desc raw-link))
1386 (concat (format "[%s]" (if (org-string-nw-p desc) desc raw-link))
1387 (unless org-e-ascii-links-to-notes (format " (%s)" raw-link)))))))
1390 ;;;; Macro
1392 (defun org-e-ascii-macro (macro contents info)
1393 "Transcode a MACRO element from Org to ASCII.
1394 CONTENTS is nil. INFO is a plist holding contextual
1395 information."
1396 (org-export-expand-macro macro info))
1399 ;;;; Paragraph
1401 (defun org-e-ascii-paragraph (paragraph contents info)
1402 "Transcode a PARAGRAPH element from Org to ASCII.
1403 CONTENTS is the contents of the paragraph, as a string. INFO is
1404 the plist used as a communication channel."
1405 (org-e-ascii--fill-string
1406 (let ((parent (car (plist-get info :genealogy))))
1407 ;; If PARAGRAPH is the first one in a list element, be sure to
1408 ;; add the check-box in front of it, before any filling. Later,
1409 ;; it would interfere with line width.
1410 (if (and (eq (car parent) 'item)
1411 (equal (car (org-element-get-contents parent)) paragraph))
1412 (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
1413 (concat (case (org-element-get-property :checkbox parent)
1414 (on (if utf8p "☑ " "[X] "))
1415 (off (if utf8p "☐ " "[ ] "))
1416 (trans (if utf8p "☒ " "[-] ")))
1417 contents))
1418 contents))
1419 (org-e-ascii--current-text-width paragraph info) info))
1422 ;;;; Plain List
1424 (defun org-e-ascii-plain-list (plain-list contents info)
1425 "Transcode a PLAIN-LIST element from Org to ASCII.
1426 CONTENTS is the contents of the list. INFO is a plist holding
1427 contextual information."
1428 contents)
1431 ;;;; Plain Text
1433 (defun org-e-ascii-plain-text (text info)
1434 "Transcode a TEXT string from Org to ASCII.
1435 INFO is a plist used as a communication channel."
1436 (if (not (and (eq (plist-get info :ascii-charset) 'utf-8)
1437 (plist-get info :with-special-strings)))
1438 text
1439 ;; Usual replacements in utf-8 with proper option set.
1440 (replace-regexp-in-string
1441 "\\.\\.\\." "…"
1442 (replace-regexp-in-string
1443 "--" "–"
1444 (replace-regexp-in-string "---" "—" text)))))
1447 ;;;; Property Drawer
1449 (defun org-e-ascii-property-drawer (property-drawer contents info)
1450 "Transcode a PROPERTY-DRAWER element from Org to ASCII.
1451 CONTENTS is nil. INFO is a plist used as a communication
1452 channel."
1453 ;; The property drawer isn't exported but we want separating blank
1454 ;; lines nonetheless.
1458 ;;;; Quote Block
1460 (defun org-e-ascii-quote-block (quote-block contents info)
1461 "Transcode a QUOTE-BLOCK element from Org to ASCII.
1462 CONTENTS holds the contents of the block. INFO is a plist
1463 holding contextual information."
1464 (let ((width (org-e-ascii--current-text-width quote-block info)))
1465 (org-e-ascii--indent-string
1466 (org-remove-indentation
1467 (org-e-ascii--fill-string contents width info))
1468 org-e-ascii-quote-margin)))
1471 ;;;; Quote Section
1473 (defun org-e-ascii-quote-section (quote-section contents info)
1474 "Transcode a QUOTE-SECTION element from Org to ASCII.
1475 CONTENTS is nil. INFO is a plist holding contextual information."
1476 (let ((width (org-e-ascii--current-text-width quote-section info))
1477 (value
1478 (org-export-secondary-string
1479 (org-remove-indentation
1480 (org-element-get-property :value quote-section)) 'e-ascii info)))
1481 (org-e-ascii--indent-string
1482 value
1483 (+ org-e-ascii-quote-margin
1484 ;; Don't apply inner margin if parent headline is low level.
1485 (let ((headline (org-export-get-parent-headline quote-section info)))
1486 (if (org-export-low-level-p headline info) 0
1487 org-e-ascii-inner-margin))))))
1490 ;;;; Radio Target
1492 (defun org-e-ascii-radio-target (radio-target contents info)
1493 "Transcode a RADIO-TARGET object from Org to ASCII.
1494 CONTENTS is the contents of the target. INFO is a plist holding
1495 contextual information."
1496 contents)
1498 ;;;; Section
1500 (defun org-e-ascii-section (section contents info)
1501 "Transcode a SECTION element from Org to ASCII.
1502 CONTENTS is the contents of the section. INFO is a plist holding
1503 contextual information."
1504 (org-e-ascii--indent-string
1505 (concat
1506 contents
1507 (when org-e-ascii-links-to-notes
1508 ;; Add list of links at the end of SECTION.
1509 (let ((links (org-e-ascii--describe-links
1510 (org-e-ascii--unique-links section info)
1511 (org-e-ascii--current-text-width section info) info)))
1512 ;; Separate list of links and section contents.
1513 (when (org-string-nw-p links) (concat "\n\n" links)))))
1514 ;; Do not apply inner margin if parent headline is low level.
1515 (let ((headline (org-export-get-parent-headline section info)))
1516 (if (or (not headline) (org-export-low-level-p headline info)) 0
1517 org-e-ascii-inner-margin))))
1520 ;;;; Special Block
1522 (defun org-e-ascii-special-block (special-block contents info)
1523 "Transcode a SPECIAL-BLOCK element from Org to ASCII.
1524 CONTENTS holds the contents of the block. INFO is a plist
1525 holding contextual information."
1526 contents)
1529 ;;;; Src Block
1531 (defun org-e-ascii-src-block (src-block contents info)
1532 "Transcode a SRC-BLOCK element from Org to ASCII.
1533 CONTENTS holds the contents of the item. INFO is a plist holding
1534 contextual information."
1535 (let ((caption (org-e-ascii--build-caption src-block info)))
1536 (concat
1537 (when (and caption org-e-ascii-caption-above) (concat caption "\n"))
1538 (org-e-ascii--box-string (org-export-handle-code src-block info) info)
1539 (when (and caption (not org-e-ascii-caption-above))
1540 (concat "\n" caption)))))
1542 ;;;; Statistics Cookie
1544 (defun org-e-ascii-statistics-cookie (statistics-cookie contents info)
1545 "Transcode a STATISTICS-COOKIE object from Org to ASCII.
1546 CONTENTS is nil. INFO is a plist holding contextual information."
1547 (org-element-get-property :value statistics-cookie))
1550 ;;;; Subscript
1552 (defun org-e-ascii-subscript (subscript contents info)
1553 "Transcode a SUBSCRIPT object from Org to ASCII.
1554 CONTENTS is the contents of the object. INFO is a plist holding
1555 contextual information."
1556 (if (org-element-get-property :use-brackets-p subscript)
1557 (format "_{%s}" contents)
1558 (format "_%s" contents)))
1561 ;;;; Superscript
1563 (defun org-e-ascii-superscript (superscript contents info)
1564 "Transcode a SUPERSCRIPT object from Org to ASCII.
1565 CONTENTS is the contents of the object. INFO is a plist holding
1566 contextual information."
1567 (if (org-element-get-property :use-brackets-p superscript)
1568 (format "_{%s}" contents)
1569 (format "_%s" contents)))
1572 ;;;; Table
1574 ;; While `org-e-ascii-table' is the callback function expected by
1575 ;; org-export mechanism, it requires four subroutines to display
1576 ;; tables accordingly to chosen charset, alignment and width
1577 ;; specifications.
1579 ;; Thus, `org-e-ascii-table--column-width' computes the display width
1580 ;; for each column in the table,
1581 ;; `org-e-ascii-table--vertical-separators' returns a vector
1582 ;; containing separators (or lack thereof),
1583 ;; `org-e-ascii-table--build-hline' creates various hline strings,
1584 ;; depending on charset, separators and position within the tabl and
1585 ;; `org-e-ascii-table--format-cell' properly aligns contents within
1586 ;; a given cell and width.
1588 (defun org-e-ascii-table (table contents info)
1589 "Transcode a TABLE element from Org to ASCII.
1590 CONTENTS is nil. INFO is a plist holding contextual information."
1591 (let ((raw-table (org-element-get-property :raw-table table))
1592 (caption (org-e-ascii--build-caption table info)))
1593 (concat
1594 ;; Possibly add a caption string above.
1595 (when (and caption org-e-ascii-caption-above) (concat caption "\n"))
1596 ;; Insert table. Note: "table.el" tables are left unmodified.
1597 (if (eq (org-element-get-property :type table) 'table.el) raw-table
1598 (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
1599 ;; Extract information out of the raw table (TABLE-INFO)
1600 ;; and clean it (CLEAN-TABLE).
1601 (table-info (org-export-table-format-info raw-table))
1602 (special-col-p (plist-get table-info :special-column-p))
1603 (alignment (plist-get table-info :alignment))
1604 (clean-table (org-export-clean-table raw-table special-col-p))
1605 ;; Change table into lisp, much like `org-table-to-lisp',
1606 ;; being more careful about keeping the exact length of
1607 ;; cells, for alignment purpose.
1608 (lisp-table
1609 (mapcar
1610 (lambda (line)
1611 (if (string-match org-table-hline-regexp line) 'hline
1612 (org-split-string (org-trim line) "\\s-?|\\s-?")))
1613 (org-split-string clean-table "[ \t]*\n[ \t]*")))
1614 ;; Compute real column widths.
1615 (column-widths
1616 (org-e-ascii-table--column-width lisp-table table-info))
1617 ;; Construct separators according to column groups.
1618 (separators (org-e-ascii-table--vertical-separators table-info))
1619 ;; Build different `hline' strings, depending on
1620 ;; separators, column widths and position.
1621 (hline-standard
1622 (org-e-ascii-table--build-hline
1623 nil separators column-widths info))
1624 (hline-top
1625 (and utf8p (org-e-ascii-table--build-hline
1626 'top separators column-widths info)))
1627 (hline-bottom
1628 (and utf8p (org-e-ascii-table--build-hline
1629 'bottom separators column-widths info))))
1630 ;; Now build table back, with correct alignment, considering
1631 ;; columns widths and separators.
1632 (mapconcat
1633 (lambda (line)
1634 (cond
1635 ((eq line 'hline) hline-standard)
1636 ((eq line 'hline-bottom) hline-bottom)
1637 ((eq line 'hline-top) hline-top)
1638 (t (loop for cell in line
1639 for col from 0 to (length line)
1640 concat
1641 (concat
1642 (let ((sep (aref separators col)))
1643 (if (and utf8p (not (string= sep ""))) "│" sep))
1644 (org-e-ascii-table--format-cell
1645 cell col column-widths alignment info)) into l
1646 finally return
1647 (concat l
1648 (let ((sep (aref separators col)))
1649 (if (and utf8p (not (string= sep ""))) "│"
1650 sep)))))))
1651 ;; If charset is `utf-8', make sure lisp-table always starts
1652 ;; with `hline-top' and ends with `hline-bottom'.
1653 (if (not utf8p) lisp-table
1654 (setq lisp-table
1655 (cons 'hline-top
1656 (if (eq (car lisp-table) 'hline) (cdr lisp-table)
1657 lisp-table)))
1658 (setq lisp-table
1659 (nconc
1660 (if (eq (car (last lisp-table)) 'hline) (butlast lisp-table)
1661 lisp-table)
1662 '(hline-bottom)))) "\n")))
1663 ;; Possible add a caption string below.
1664 (when (and caption (not org-e-ascii-caption-above))
1665 (concat "\n" caption)))))
1667 (defun org-e-ascii-table--column-width (table table-info)
1668 "Return vector of TABLE columns width.
1670 TABLE is the Lisp representation of the Org table considered.
1671 TABLE-INFO holds information about the table. See
1672 `org-export-table-format-info'.
1674 Unlike to `:width' property from `org-export-table-format-info',
1675 the return value contains width of every column, not only those
1676 with a width cookie."
1677 (let* ((cookies (plist-get table-info :width))
1678 (width (make-vector (length cookies) 0)))
1679 (mapc
1680 (lambda (line)
1681 (let ((idx 0))
1682 (unless (eq line 'hline)
1683 (mapc (lambda (cell)
1684 (let ((len (length cell)))
1685 (when (> len (aref width idx)) (aset width idx len)))
1686 (incf idx))
1687 line))))
1688 table)
1689 (unless org-e-ascii-table-widen-columns
1690 ;; When colums are not widened, width cookies have precedence
1691 ;; over string lengths. Thus, overwrite the latter with the
1692 ;; former.
1693 (loop for w across cookies
1694 for idx from 0 to (length cookies)
1695 when w do (aset width idx w)))
1696 ;; Return value.
1697 width))
1699 (defun org-e-ascii-table--vertical-separators (table-info)
1700 "Return a vector of strings for vertical separators.
1702 TABLE-INFO holds information about considered table. See
1703 `org-export-table-format-info'.
1705 Return value is a vector whose length is one more than the number
1706 of columns in the table. Special column, if any, is ignored."
1707 (let* ((colgroups (plist-get table-info :column-groups))
1708 (separators (make-vector (1+ (length colgroups)) "")))
1709 (if org-e-ascii-table-keep-all-vertical-lines
1710 (make-vector (length separators) "|")
1711 (let ((column 0))
1712 (mapc (lambda (group)
1713 (when (memq group '(start start-end))
1714 (aset separators column "|"))
1715 (when (memq group '(end start-end))
1716 (aset separators (1+ column) "|"))
1717 (incf column))
1718 colgroups)
1719 ;; Remove unneeded special column.
1720 (if (not (plist-get table-info :special-column-p)) separators
1721 (substring separators 1))))))
1723 (defun org-e-ascii-table--format-cell (cell col width alignment info)
1724 "Format CELL with column width and alignment constraints.
1726 CELL is the contents of the cell, as a string.
1728 COL is the column containing the cell considered.
1730 WIDTH is a vector holding every column width, as returned by
1731 `org-e-ascii-table--column-width'.
1733 ALIGNMENT is a vector containing alignment strings for every
1734 column.
1736 INFO is a plist used as a communication channel."
1737 (let ((col-width (if org-e-ascii-table-widen-columns (aref width col)
1738 (or (aref width col) (length cell)))))
1739 ;; When CELL is too large, it has to be truncated.
1740 (unless (or org-e-ascii-table-widen-columns (<= (length cell) col-width))
1741 (setq cell (concat (substring cell 0 (- col-width 2)) "=>")))
1742 (let* ((indent-tabs-mode nil)
1743 (align (aref alignment col))
1744 (aligned-cell
1745 (org-e-ascii--justify-string
1746 (org-trim cell) col-width
1747 (cond ((string= align "c") 'center)
1748 ((string= align "r") 'right)))))
1749 ;; Return aligned cell, with missing white spaces added and
1750 ;; space separators between columns.
1751 (format
1752 " %s "
1753 (concat aligned-cell
1754 (make-string (- col-width (length aligned-cell)) ? ))))))
1756 (defun org-e-ascii-table--build-hline (position separators column-widths info)
1757 "Return string used as an horizontal line in tables.
1759 POSITION is a symbol among `top', `bottom' and nil, which
1760 specifies position of the horizontal line within the table.
1762 SEPARATORS is a vector strings specifying separators used in the
1763 table, as returned by `org-e-ascii-table--vertical-separators'.
1765 COLUMN-WIDTHS is a vector of numbers specifying widths of all
1766 columns in the table, as returned by
1767 `org-e-ascii-table--column-width'.
1769 INFO is a plist used as a communication channel."
1770 (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
1771 (loop for idx from 0 to (length separators)
1772 for width across column-widths
1773 concat
1774 (concat
1775 (cond ((string= (aref separators idx) "") nil)
1776 ((and utf8p (zerop idx))
1777 (cond ((eq position 'top) "┍")
1778 ((eq position 'bottom) "┕")
1779 (t "├")))
1780 (utf8p
1781 (cond ((eq position 'top) "┯")
1782 ((eq position 'bottom) "┷")
1783 (t "┼")))
1784 (t "+"))
1785 ;; Hline has to cover all the cell and
1786 ;; both white spaces between columns.
1787 (make-string (+ width 2)
1788 (cond ((not utf8p) ?-)
1789 ((not position) ?─)
1790 (t ?━))))
1791 into hline
1792 finally return
1793 (concat
1794 hline
1795 (cond
1796 ((string= (aref separators idx) "") nil)
1797 (utf8p (cond ((eq position 'top) "┑")
1798 ((eq position 'bottom) "┙")
1799 (t "┤")))
1800 (t "+"))))))
1803 ;;;; Target
1805 (defun org-e-ascii-target (target contents info)
1806 "Transcode a TARGET object from Org to ASCII.
1807 CONTENTS is the contents of the target. INFO is a plist holding
1808 contextual information."
1809 contents)
1812 ;;;; Time-stamp
1814 (defun org-e-ascii-time-stamp (time-stamp contents info)
1815 "Transcode a TIME-STAMP object from Org to ASCII.
1816 CONTENTS is nil. INFO is a plist holding contextual information."
1817 ;; Return time-stamps as-is.
1818 (org-element-time-stamp-interpreter time-stamp contents))
1821 ;;;; Verbatim
1823 (defun org-e-ascii-verbatim (verbatim contents info)
1824 "Return a VERBATIM object from Org to ASCII.
1825 CONTENTS is nil. INFO is a plist holding contextual information."
1826 (format org-e-ascii-verbatim-format
1827 (org-element-get-property :value verbatim)))
1830 ;;;; Verse Block
1832 (defun org-e-ascii-verse-block (verse-block contents info)
1833 "Transcode a VERSE-BLOCK element from Org to ASCII.
1834 CONTENTS is nil. INFO is a plist holding contextual information."
1835 (let ((verse-width (org-e-ascii--current-text-width verse-block info)))
1836 (org-e-ascii--indent-string
1837 (org-e-ascii--justify-string
1838 (org-export-secondary-string
1839 (org-element-get-property :value verse-block) 'e-ascii info)
1840 verse-width 'left)
1841 org-e-ascii-quote-margin)))
1844 ;;; Filter
1846 (defun org-e-ascii-filter-headline-blank-lines (headline back-end)
1847 "Filter controlling number of blank lines after an headline.
1849 HEADLINE is a string representing a transcoded headline.
1850 BACK-END is symbol specifying back-end used for export.
1852 This function only applies to `e-ascii' back-end. See
1853 `org-e-ascii-headline-spacing' for information.
1855 For any other back-end, HEADLINE is returned as-is."
1856 (if (not (and (eq back-end 'e-ascii) org-e-ascii-headline-spacing)) headline
1857 (let ((blanks (make-string (1+ (cdr org-e-ascii-headline-spacing)) ?\n)))
1858 (replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline))))
1862 ;;; Interactive function
1864 (defun org-e-ascii-export-to-ascii
1865 (&optional subtreep visible-only body-only ext-plist pub-dir)
1866 "Export current buffer to a text file.
1868 If narrowing is active in the current buffer, only export its
1869 narrowed part.
1871 If a region is active, export that region.
1873 When optional argument SUBTREEP is non-nil, export the sub-tree
1874 at point, extracting information from the headline properties
1875 first.
1877 When optional argument VISIBLE-ONLY is non-nil, don't export
1878 contents of hidden elements.
1880 When optional argument BODY-ONLY is non-nil, strip title, table
1881 of contents and footnote definitions from output.
1883 EXT-PLIST, when provided, is a property list with external
1884 parameters overriding Org default settings, but still inferior to
1885 file-local settings.
1887 When optional argument PUB-DIR is set, use it as the publishing
1888 directory.
1890 Return output file's name."
1891 (interactive)
1892 (let ((outfile (org-export-output-file-name ".txt" subtreep pub-dir)))
1893 (org-export-to-file
1894 'e-ascii outfile subtreep visible-only body-only ext-plist)))
1897 (provide 'org-e-ascii)
1898 ;;; org-e-ascii.el ends here