* src/intervals.c (rotate_right, rotate_left): Fix up length computation.
[emacs.git] / lisp / org / ox-ascii.el
blobdc238adc7817263994d93dffa6dacfa3310458cc
1 ;;; ox-ascii.el --- ASCII Back-End for Org Export Engine
3 ;; Copyright (C) 2012-2014 Free Software Foundation, Inc.
5 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
6 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; This library implements an ASCII back-end for Org generic exporter.
26 ;; See Org manual for more information.
28 ;;; Code:
30 (eval-when-compile (require 'cl))
31 (require 'ox)
32 (require 'ox-publish)
34 (declare-function aa2u "ext:ascii-art-to-unicode" ())
36 ;;; Define Back-End
38 ;; The following setting won't allow to modify preferred charset
39 ;; through a buffer keyword or an option item, but, since the property
40 ;; will appear in communication channel nonetheless, it allows to
41 ;; override `org-ascii-charset' variable on the fly by the ext-plist
42 ;; mechanism.
44 ;; We also install a filter for headlines and sections, in order to
45 ;; control blank lines separating them in output string.
47 (org-export-define-backend 'ascii
48 '((bold . org-ascii-bold)
49 (center-block . org-ascii-center-block)
50 (clock . org-ascii-clock)
51 (code . org-ascii-code)
52 (comment . (lambda (&rest args) ""))
53 (comment-block . (lambda (&rest args) ""))
54 (drawer . org-ascii-drawer)
55 (dynamic-block . org-ascii-dynamic-block)
56 (entity . org-ascii-entity)
57 (example-block . org-ascii-example-block)
58 (export-block . org-ascii-export-block)
59 (export-snippet . org-ascii-export-snippet)
60 (fixed-width . org-ascii-fixed-width)
61 (footnote-reference . org-ascii-footnote-reference)
62 (headline . org-ascii-headline)
63 (horizontal-rule . org-ascii-horizontal-rule)
64 (inline-src-block . org-ascii-inline-src-block)
65 (inlinetask . org-ascii-inlinetask)
66 (inner-template . org-ascii-inner-template)
67 (italic . org-ascii-italic)
68 (item . org-ascii-item)
69 (keyword . org-ascii-keyword)
70 (latex-environment . org-ascii-latex-environment)
71 (latex-fragment . org-ascii-latex-fragment)
72 (line-break . org-ascii-line-break)
73 (link . org-ascii-link)
74 (paragraph . org-ascii-paragraph)
75 (plain-list . org-ascii-plain-list)
76 (plain-text . org-ascii-plain-text)
77 (planning . org-ascii-planning)
78 (quote-block . org-ascii-quote-block)
79 (quote-section . org-ascii-quote-section)
80 (radio-target . org-ascii-radio-target)
81 (section . org-ascii-section)
82 (special-block . org-ascii-special-block)
83 (src-block . org-ascii-src-block)
84 (statistics-cookie . org-ascii-statistics-cookie)
85 (strike-through . org-ascii-strike-through)
86 (subscript . org-ascii-subscript)
87 (superscript . org-ascii-superscript)
88 (table . org-ascii-table)
89 (table-cell . org-ascii-table-cell)
90 (table-row . org-ascii-table-row)
91 (target . org-ascii-target)
92 (template . org-ascii-template)
93 (timestamp . org-ascii-timestamp)
94 (underline . org-ascii-underline)
95 (verbatim . org-ascii-verbatim)
96 (verse-block . org-ascii-verse-block))
97 :export-block "ASCII"
98 :menu-entry
99 '(?t "Export to Plain Text"
100 ((?A "As ASCII buffer"
101 (lambda (a s v b)
102 (org-ascii-export-as-ascii a s v b '(:ascii-charset ascii))))
103 (?a "As ASCII file"
104 (lambda (a s v b)
105 (org-ascii-export-to-ascii a s v b '(:ascii-charset ascii))))
106 (?L "As Latin1 buffer"
107 (lambda (a s v b)
108 (org-ascii-export-as-ascii a s v b '(:ascii-charset latin1))))
109 (?l "As Latin1 file"
110 (lambda (a s v b)
111 (org-ascii-export-to-ascii a s v b '(:ascii-charset latin1))))
112 (?U "As UTF-8 buffer"
113 (lambda (a s v b)
114 (org-ascii-export-as-ascii a s v b '(:ascii-charset utf-8))))
115 (?u "As UTF-8 file"
116 (lambda (a s v b)
117 (org-ascii-export-to-ascii a s v b '(:ascii-charset utf-8))))))
118 :filters-alist '((:filter-headline . org-ascii-filter-headline-blank-lines)
119 (:filter-parse-tree org-ascii-filter-paragraph-spacing
120 org-ascii-filter-comment-spacing)
121 (:filter-section . org-ascii-filter-headline-blank-lines))
122 :options-alist '((:ascii-charset nil nil org-ascii-charset)))
126 ;;; User Configurable Variables
128 (defgroup org-export-ascii nil
129 "Options for exporting Org mode files to ASCII."
130 :tag "Org Export ASCII"
131 :group 'org-export)
133 (defcustom org-ascii-text-width 72
134 "Maximum width of exported text.
135 This number includes margin size, as set in
136 `org-ascii-global-margin'."
137 :group 'org-export-ascii
138 :version "24.4"
139 :package-version '(Org . "8.0")
140 :type 'integer)
142 (defcustom org-ascii-global-margin 0
143 "Width of the left margin, in number of characters."
144 :group 'org-export-ascii
145 :version "24.4"
146 :package-version '(Org . "8.0")
147 :type 'integer)
149 (defcustom org-ascii-inner-margin 2
150 "Width of the inner margin, in number of characters.
151 Inner margin is applied between each headline."
152 :group 'org-export-ascii
153 :version "24.4"
154 :package-version '(Org . "8.0")
155 :type 'integer)
157 (defcustom org-ascii-quote-margin 6
158 "Width of margin used for quoting text, in characters.
159 This margin is applied on both sides of the text."
160 :group 'org-export-ascii
161 :version "24.4"
162 :package-version '(Org . "8.0")
163 :type 'integer)
165 (defcustom org-ascii-inlinetask-width 30
166 "Width of inline tasks, in number of characters.
167 This number ignores any margin."
168 :group 'org-export-ascii
169 :version "24.4"
170 :package-version '(Org . "8.0")
171 :type 'integer)
173 (defcustom org-ascii-headline-spacing '(1 . 2)
174 "Number of blank lines inserted around headlines.
176 This variable can be set to a cons cell. In that case, its car
177 represents the number of blank lines present before headline
178 contents whereas its cdr reflects the number of blank lines after
179 contents.
181 A nil value replicates the number of blank lines found in the
182 original Org buffer at the same place."
183 :group 'org-export-ascii
184 :version "24.4"
185 :package-version '(Org . "8.0")
186 :type '(choice
187 (const :tag "Replicate original spacing" nil)
188 (cons :tag "Set an uniform spacing"
189 (integer :tag "Number of blank lines before contents")
190 (integer :tag "Number of blank lines after contents"))))
192 (defcustom org-ascii-indented-line-width 'auto
193 "Additional indentation width for the first line in a paragraph.
194 If the value is an integer, indent the first line of each
195 paragraph by this number. If it is the symbol `auto' preserve
196 indentation from original document."
197 :group 'org-export-ascii
198 :version "24.4"
199 :package-version '(Org . "8.0")
200 :type '(choice
201 (integer :tag "Number of white spaces characters")
202 (const :tag "Preserve original width" auto)))
204 (defcustom org-ascii-paragraph-spacing 'auto
205 "Number of white lines between paragraphs.
206 If the value is an integer, add this number of blank lines
207 between contiguous paragraphs. If is it the symbol `auto', keep
208 the same number of blank lines as in the original document."
209 :group 'org-export-ascii
210 :version "24.4"
211 :package-version '(Org . "8.0")
212 :type '(choice
213 (integer :tag "Number of blank lines")
214 (const :tag "Preserve original spacing" auto)))
216 (defcustom org-ascii-charset 'ascii
217 "The charset allowed to represent various elements and objects.
218 Possible values are:
219 `ascii' Only use plain ASCII characters
220 `latin1' Include Latin-1 characters
221 `utf-8' Use all UTF-8 characters"
222 :group 'org-export-ascii
223 :version "24.4"
224 :package-version '(Org . "8.0")
225 :type '(choice
226 (const :tag "ASCII" ascii)
227 (const :tag "Latin-1" latin1)
228 (const :tag "UTF-8" utf-8)))
230 (defcustom org-ascii-underline '((ascii ?= ?~ ?-)
231 (latin1 ?= ?~ ?-)
232 (utf-8 ?═ ?─ ?╌ ?┄ ?┈))
233 "Characters for underlining headings in ASCII export.
235 Alist whose key is a symbol among `ascii', `latin1' and `utf-8'
236 and whose value is a list of characters.
238 For each supported charset, this variable associates a sequence
239 of underline characters. In a sequence, the characters will be
240 used in order for headlines level 1, 2, ... If no character is
241 available for a given level, the headline won't be underlined."
242 :group 'org-export-ascii
243 :version "24.4"
244 :package-version '(Org . "8.0")
245 :type '(list
246 (cons :tag "Underline characters sequence"
247 (const :tag "ASCII charset" ascii)
248 (repeat character))
249 (cons :tag "Underline characters sequence"
250 (const :tag "Latin-1 charset" latin1)
251 (repeat character))
252 (cons :tag "Underline characters sequence"
253 (const :tag "UTF-8 charset" utf-8)
254 (repeat character))))
256 (defcustom org-ascii-bullets '((ascii ?* ?+ ?-)
257 (latin1 ?§ ?¶)
258 (utf-8 ?◊))
259 "Bullet characters for headlines converted to lists in ASCII export.
261 Alist whose key is a symbol among `ascii', `latin1' and `utf-8'
262 and whose value is a list of characters.
264 The first character is used for the first level considered as low
265 level, and so on. If there are more levels than characters given
266 here, the list will be repeated.
268 Note that this variable doesn't affect plain lists
269 representation."
270 :group 'org-export-ascii
271 :version "24.4"
272 :package-version '(Org . "8.0")
273 :type '(list
274 (cons :tag "Bullet characters for low level headlines"
275 (const :tag "ASCII charset" ascii)
276 (repeat character))
277 (cons :tag "Bullet characters for low level headlines"
278 (const :tag "Latin-1 charset" latin1)
279 (repeat character))
280 (cons :tag "Bullet characters for low level headlines"
281 (const :tag "UTF-8 charset" utf-8)
282 (repeat character))))
284 (defcustom org-ascii-links-to-notes t
285 "Non-nil means convert links to notes before the next headline.
286 When nil, the link will be exported in place. If the line
287 becomes long in this way, it will be wrapped."
288 :group 'org-export-ascii
289 :version "24.4"
290 :package-version '(Org . "8.0")
291 :type 'boolean)
293 (defcustom org-ascii-table-keep-all-vertical-lines nil
294 "Non-nil means keep all vertical lines in ASCII tables.
295 When nil, vertical lines will be removed except for those needed
296 for column grouping."
297 :group 'org-export-ascii
298 :version "24.4"
299 :package-version '(Org . "8.0")
300 :type 'boolean)
302 (defcustom org-ascii-table-widen-columns t
303 "Non-nil means widen narrowed columns for export.
304 When nil, narrowed columns will look in ASCII export just like in
305 Org mode, i.e. with \"=>\" as ellipsis."
306 :group 'org-export-ascii
307 :version "24.4"
308 :package-version '(Org . "8.0")
309 :type 'boolean)
311 (defcustom org-ascii-table-use-ascii-art nil
312 "Non-nil means table.el tables are turned into ascii-art.
314 It only makes sense when export charset is `utf-8'. It is nil by
315 default since it requires ascii-art-to-unicode.el package. You
316 can download it here:
318 http://gnuvola.org/software/j/aa2u/ascii-art-to-unicode.el."
319 :group 'org-export-ascii
320 :version "24.4"
321 :package-version '(Org . "8.0")
322 :type 'boolean)
324 (defcustom org-ascii-caption-above nil
325 "When non-nil, place caption string before the element.
326 Otherwise, place it right after it."
327 :group 'org-export-ascii
328 :version "24.4"
329 :package-version '(Org . "8.0")
330 :type 'boolean)
332 (defcustom org-ascii-verbatim-format "`%s'"
333 "Format string used for verbatim text and inline code."
334 :group 'org-export-ascii
335 :version "24.4"
336 :package-version '(Org . "8.0")
337 :type 'string)
339 (defcustom org-ascii-format-drawer-function
340 (lambda (name contents width) contents)
341 "Function called to format a drawer in ASCII.
343 The function must accept three parameters:
344 NAME the drawer name, like \"LOGBOOK\"
345 CONTENTS the contents of the drawer.
346 WIDTH the text width within the drawer.
348 The function should return either the string to be exported or
349 nil to ignore the drawer.
351 The default value simply returns the value of CONTENTS."
352 :group 'org-export-ascii
353 :version "24.4"
354 :package-version '(Org . "8.0")
355 :type 'function)
357 (defcustom org-ascii-format-inlinetask-function
358 'org-ascii-format-inlinetask-default
359 "Function called to format an inlinetask in ASCII.
361 The function must accept nine parameters:
362 TODO the todo keyword, as a string
363 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
364 PRIORITY the inlinetask priority, as a string
365 NAME the inlinetask name, as a string.
366 TAGS the inlinetask tags, as a list of strings.
367 CONTENTS the contents of the inlinetask, as a string.
368 WIDTH the width of the inlinetask, as a number.
369 INLINETASK the inlinetask itself.
370 INFO the info channel.
372 The function should return either the string to be exported or
373 nil to ignore the inline task."
374 :group 'org-export-ascii
375 :version "24.4"
376 :package-version '(Org . "8.3")
377 :type 'function)
381 ;;; Internal Functions
383 ;; Internal functions fall into three categories.
385 ;; The first one is about text formatting. The core function is
386 ;; `org-ascii--current-text-width', which determines the current
387 ;; text width allowed to a given element. In other words, it helps
388 ;; keeping each line width within maximum text width defined in
389 ;; `org-ascii-text-width'. Once this information is known,
390 ;; `org-ascii--fill-string', `org-ascii--justify-string',
391 ;; `org-ascii--box-string' and `org-ascii--indent-string' can
392 ;; operate on a given output string.
394 ;; The second category contains functions handling elements listings,
395 ;; triggered by "#+TOC:" keyword. As such, `org-ascii--build-toc'
396 ;; returns a complete table of contents, `org-ascii--list-listings'
397 ;; returns a list of referenceable src-block elements, and
398 ;; `org-ascii--list-tables' does the same for table elements.
400 ;; The third category includes general helper functions.
401 ;; `org-ascii--build-title' creates the title for a given headline
402 ;; or inlinetask element. `org-ascii--build-caption' returns the
403 ;; caption string associated to a table or a src-block.
404 ;; `org-ascii--describe-links' creates notes about links for
405 ;; insertion at the end of a section. It uses
406 ;; `org-ascii--unique-links' to get the list of links to describe.
407 ;; Eventually, `org-ascii--translate' translates a string according
408 ;; to language and charset specification.
411 (defun org-ascii--fill-string (s text-width info &optional justify)
412 "Fill a string with specified text-width and return it.
414 S is the string being filled. TEXT-WIDTH is an integer
415 specifying maximum length of a line. INFO is the plist used as
416 a communication channel.
418 Optional argument JUSTIFY can specify any type of justification
419 among `left', `center', `right' or `full'. A nil value is
420 equivalent to `left'. For a justification that doesn't also fill
421 string, see `org-ascii--justify-string'.
423 Return nil if S isn't a string."
424 ;; Don't fill paragraph when break should be preserved.
425 (cond ((not (stringp s)) nil)
426 ((plist-get info :preserve-breaks) s)
427 (t (let ((double-space-p sentence-end-double-space))
428 (with-temp-buffer
429 (let ((fill-column text-width)
430 (use-hard-newlines t)
431 (sentence-end-double-space double-space-p))
432 (insert s)
433 (fill-region (point-min) (point-max) justify))
434 (buffer-string))))))
436 (defun org-ascii--justify-string (s text-width how)
437 "Justify string S.
438 TEXT-WIDTH is an integer specifying maximum length of a line.
439 HOW determines the type of justification: it can be `left',
440 `right', `full' or `center'."
441 (with-temp-buffer
442 (insert s)
443 (goto-char (point-min))
444 (let ((fill-column text-width)
445 ;; Disable `adaptive-fill-mode' so it doesn't prevent
446 ;; filling lines matching `adaptive-fill-regexp'.
447 (adaptive-fill-mode nil))
448 (while (< (point) (point-max))
449 (justify-current-line how)
450 (forward-line)))
451 (buffer-string)))
453 (defun org-ascii--indent-string (s width)
454 "Indent string S by WIDTH white spaces.
455 Empty lines are not indented."
456 (when (stringp s)
457 (replace-regexp-in-string
458 "\\(^\\)\\(?:.*\\S-\\)" (make-string width ? ) s nil nil 1)))
460 (defun org-ascii--box-string (s info)
461 "Return string S with a partial box to its left.
462 INFO is a plist used as a communication channel."
463 (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
464 (format (if utf8p "╭────\n%s\n╰────" ",----\n%s\n`----")
465 (replace-regexp-in-string
466 "^" (if utf8p "│ " "| ")
467 ;; Remove last newline character.
468 (replace-regexp-in-string "\n[ \t]*\\'" "" s)))))
470 (defun org-ascii--current-text-width (element info)
471 "Return maximum text width for ELEMENT's contents.
472 INFO is a plist used as a communication channel."
473 (case (org-element-type element)
474 ;; Elements with an absolute width: `headline' and `inlinetask'.
475 (inlinetask org-ascii-inlinetask-width)
476 ('headline
477 (- org-ascii-text-width
478 (let ((low-level-rank (org-export-low-level-p element info)))
479 (if low-level-rank (* low-level-rank 2) org-ascii-global-margin))))
480 ;; Elements with a relative width: store maximum text width in
481 ;; TOTAL-WIDTH.
482 (otherwise
483 (let* ((genealogy (cons element (org-export-get-genealogy element)))
484 ;; Total width is determined by the presence, or not, of an
485 ;; inline task among ELEMENT parents.
486 (total-width
487 (if (loop for parent in genealogy
488 thereis (eq (org-element-type parent) 'inlinetask))
489 org-ascii-inlinetask-width
490 ;; No inlinetask: Remove global margin from text width.
491 (- org-ascii-text-width
492 org-ascii-global-margin
493 (let ((parent (org-export-get-parent-headline element)))
494 ;; Inner margin doesn't apply to text before first
495 ;; headline.
496 (if (not parent) 0
497 (let ((low-level-rank
498 (org-export-low-level-p parent info)))
499 ;; Inner margin doesn't apply to contents of
500 ;; low level headlines, since they've got their
501 ;; own indentation mechanism.
502 (if low-level-rank (* low-level-rank 2)
503 org-ascii-inner-margin))))))))
504 (- total-width
505 ;; Each `quote-block', `quote-section' and `verse-block' above
506 ;; narrows text width by twice the standard margin size.
507 (+ (* (loop for parent in genealogy
508 when (memq (org-element-type parent)
509 '(quote-block quote-section verse-block))
510 count parent)
511 2 org-ascii-quote-margin)
512 ;; Text width within a plain-list is restricted by
513 ;; indentation of current item. If that's the case,
514 ;; compute it with the help of `:structure' property from
515 ;; parent item, if any.
516 (let ((parent-item
517 (if (eq (org-element-type element) 'item) element
518 (loop for parent in genealogy
519 when (eq (org-element-type parent) 'item)
520 return parent))))
521 (if (not parent-item) 0
522 ;; Compute indentation offset of the current item,
523 ;; that is the sum of the difference between its
524 ;; indentation and the indentation of the top item in
525 ;; the list and current item bullet's length. Also
526 ;; remove checkbox length, and tag length (for
527 ;; description lists) or bullet length.
528 (let ((struct (org-element-property :structure parent-item))
529 (beg-item (org-element-property :begin parent-item)))
530 (+ (- (org-list-get-ind beg-item struct)
531 (org-list-get-ind
532 (org-list-get-top-point struct) struct))
533 (length (org-ascii--checkbox parent-item info))
534 (length
535 (or (org-list-get-tag beg-item struct)
536 (org-list-get-bullet beg-item struct)))))))))))))
538 (defun org-ascii--build-title
539 (element info text-width &optional underline notags toc)
540 "Format ELEMENT title and return it.
542 ELEMENT is either an `headline' or `inlinetask' element. INFO is
543 a plist used as a communication channel. TEXT-WIDTH is an
544 integer representing the maximum length of a line.
546 When optional argument UNDERLINE is non-nil, underline title,
547 without the tags, according to `org-ascii-underline'
548 specifications.
550 If optional argument NOTAGS is non-nil, no tags will be added to
551 the title.
553 When optional argument TOC is non-nil, use optional title if
554 possible. It doesn't apply to `inlinetask' elements."
555 (let* ((headlinep (eq (org-element-type element) 'headline))
556 (numbers
557 ;; Numbering is specific to headlines.
558 (and headlinep (org-export-numbered-headline-p element info)
559 ;; All tests passed: build numbering string.
560 (concat
561 (mapconcat
562 'number-to-string
563 (org-export-get-headline-number element info) ".")
564 " ")))
565 (text
566 (org-trim
567 (org-export-data
568 (if (and toc headlinep) (org-export-get-alt-title element info)
569 (org-element-property :title element))
570 info)))
571 (todo
572 (and (plist-get info :with-todo-keywords)
573 (let ((todo (org-element-property :todo-keyword element)))
574 (and todo (concat (org-export-data todo info) " ")))))
575 (tags (and (not notags)
576 (plist-get info :with-tags)
577 (let ((tag-list (org-export-get-tags element info)))
578 (and tag-list
579 (format ":%s:"
580 (mapconcat 'identity tag-list ":"))))))
581 (priority
582 (and (plist-get info :with-priority)
583 (let ((char (org-element-property :priority element)))
584 (and char (format "(#%c) " char)))))
585 (first-part (concat numbers todo priority text)))
586 (concat
587 first-part
588 ;; Align tags, if any.
589 (when tags
590 (format
591 (format " %%%ds"
592 (max (- text-width (1+ (length first-part))) (length tags)))
593 tags))
594 ;; Maybe underline text, if ELEMENT type is `headline' and an
595 ;; underline character has been defined.
596 (when (and underline headlinep)
597 (let ((under-char
598 (nth (1- (org-export-get-relative-level element info))
599 (cdr (assq (plist-get info :ascii-charset)
600 org-ascii-underline)))))
601 (and under-char
602 (concat "\n"
603 (make-string (length first-part) under-char))))))))
605 (defun org-ascii--has-caption-p (element info)
606 "Non-nil when ELEMENT has a caption affiliated keyword.
607 INFO is a plist used as a communication channel. This function
608 is meant to be used as a predicate for `org-export-get-ordinal'."
609 (org-element-property :caption element))
611 (defun org-ascii--build-caption (element info)
612 "Return caption string for ELEMENT, if applicable.
614 INFO is a plist used as a communication channel.
616 The caption string contains the sequence number of ELEMENT along
617 with its real caption. Return nil when ELEMENT has no affiliated
618 caption keyword."
619 (let ((caption (org-export-get-caption element)))
620 (when caption
621 ;; Get sequence number of current src-block among every
622 ;; src-block with a caption.
623 (let ((reference
624 (org-export-get-ordinal
625 element info nil 'org-ascii--has-caption-p))
626 (title-fmt (org-ascii--translate
627 (case (org-element-type element)
628 (table "Table %d:")
629 (src-block "Listing %d:"))
630 info)))
631 (org-ascii--fill-string
632 (concat (format title-fmt reference)
634 (org-export-data caption info))
635 (org-ascii--current-text-width element info) info)))))
637 (defun org-ascii--build-toc (info &optional n keyword)
638 "Return a table of contents.
640 INFO is a plist used as a communication channel.
642 Optional argument N, when non-nil, is an integer specifying the
643 depth of the table.
645 Optional argument KEYWORD specifies the TOC keyword, if any, from
646 which the table of contents generation has been initiated."
647 (let ((title (org-ascii--translate "Table of Contents" info)))
648 (concat
649 title "\n"
650 (make-string (length title)
651 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
652 "\n\n"
653 (let ((text-width
654 (if keyword (org-ascii--current-text-width keyword info)
655 (- org-ascii-text-width org-ascii-global-margin))))
656 (mapconcat
657 (lambda (headline)
658 (let* ((level (org-export-get-relative-level headline info))
659 (indent (* (1- level) 3)))
660 (concat
661 (unless (zerop indent) (concat (make-string (1- indent) ?.) " "))
662 (org-ascii--build-title
663 headline info (- text-width indent) nil
664 (or (not (plist-get info :with-tags))
665 (eq (plist-get info :with-tags) 'not-in-toc))
666 'toc))))
667 (org-export-collect-headlines info n) "\n")))))
669 (defun org-ascii--list-listings (keyword info)
670 "Return a list of listings.
672 KEYWORD is the keyword that initiated the list of listings
673 generation. INFO is a plist used as a communication channel."
674 (let ((title (org-ascii--translate "List of Listings" info)))
675 (concat
676 title "\n"
677 (make-string (length title)
678 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
679 "\n\n"
680 (let ((text-width
681 (if keyword (org-ascii--current-text-width keyword info)
682 (- org-ascii-text-width org-ascii-global-margin)))
683 ;; Use a counter instead of retrieving ordinal of each
684 ;; src-block.
685 (count 0))
686 (mapconcat
687 (lambda (src-block)
688 ;; Store initial text so its length can be computed. This is
689 ;; used to properly align caption right to it in case of
690 ;; filling (like contents of a description list item).
691 (let ((initial-text
692 (format (org-ascii--translate "Listing %d:" info)
693 (incf count))))
694 (concat
695 initial-text " "
696 (org-trim
697 (org-ascii--indent-string
698 (org-ascii--fill-string
699 ;; Use short name in priority, if available.
700 (let ((caption (or (org-export-get-caption src-block t)
701 (org-export-get-caption src-block))))
702 (org-export-data caption info))
703 (- text-width (length initial-text)) info)
704 (length initial-text))))))
705 (org-export-collect-listings info) "\n")))))
707 (defun org-ascii--list-tables (keyword info)
708 "Return a list of tables.
710 KEYWORD is the keyword that initiated the list of tables
711 generation. INFO is a plist used as a communication channel."
712 (let ((title (org-ascii--translate "List of Tables" info)))
713 (concat
714 title "\n"
715 (make-string (length title)
716 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))
717 "\n\n"
718 (let ((text-width
719 (if keyword (org-ascii--current-text-width keyword info)
720 (- org-ascii-text-width org-ascii-global-margin)))
721 ;; Use a counter instead of retrieving ordinal of each
722 ;; src-block.
723 (count 0))
724 (mapconcat
725 (lambda (table)
726 ;; Store initial text so its length can be computed. This is
727 ;; used to properly align caption right to it in case of
728 ;; filling (like contents of a description list item).
729 (let ((initial-text
730 (format (org-ascii--translate "Table %d:" info)
731 (incf count))))
732 (concat
733 initial-text " "
734 (org-trim
735 (org-ascii--indent-string
736 (org-ascii--fill-string
737 ;; Use short name in priority, if available.
738 (let ((caption (or (org-export-get-caption table t)
739 (org-export-get-caption table))))
740 (org-export-data caption info))
741 (- text-width (length initial-text)) info)
742 (length initial-text))))))
743 (org-export-collect-tables info) "\n")))))
745 (defun org-ascii--unique-links (element info)
746 "Return a list of unique link references in ELEMENT.
748 ELEMENT is either a headline element or a section element. INFO
749 is a plist used as a communication channel."
750 (let* (seen
751 (unique-link-p
752 (function
753 ;; Return LINK if it wasn't referenced so far, or nil.
754 ;; Update SEEN links along the way.
755 (lambda (link)
756 (let ((footprint
757 (cons (org-element-property :raw-link link)
758 (org-element-contents link))))
759 ;; Ignore LINK if it hasn't been translated already.
760 ;; It can happen if it is located in an affiliated
761 ;; keyword that was ignored.
762 (when (and (org-string-nw-p
763 (gethash link (plist-get info :exported-data)))
764 (not (member footprint seen)))
765 (push footprint seen) link)))))
766 ;; If at a section, find parent headline, if any, in order to
767 ;; count links that might be in the title.
768 (headline
769 (if (eq (org-element-type element) 'headline) element
770 (or (org-export-get-parent-headline element) element))))
771 ;; Get all links in HEADLINE.
772 (org-element-map headline 'link
773 (lambda (l) (funcall unique-link-p l)) info nil nil t)))
775 (defun org-ascii--describe-links (links width info)
776 "Return a string describing a list of links.
778 LINKS is a list of link type objects, as returned by
779 `org-ascii--unique-links'. WIDTH is the text width allowed for
780 the output string. INFO is a plist used as a communication
781 channel."
782 (mapconcat
783 (lambda (link)
784 (let ((type (org-element-property :type link))
785 (anchor (let ((desc (org-element-contents link)))
786 (if desc (org-export-data desc info)
787 (org-element-property :raw-link link)))))
788 (cond
789 ;; Coderefs, radio links and fuzzy links are ignored.
790 ((member type '("coderef" "radio" "fuzzy")) nil)
791 ;; Id and custom-id links: Headlines refer to their numbering.
792 ((member type '("custom-id" "id"))
793 (let ((dest (org-export-resolve-id-link link info)))
794 (concat
795 (org-ascii--fill-string
796 (format
797 "[%s] %s"
798 anchor
799 (if (not dest) (org-ascii--translate "Unknown reference" info)
800 (format
801 (org-ascii--translate "See section %s" info)
802 (mapconcat 'number-to-string
803 (org-export-get-headline-number dest info) "."))))
804 width info) "\n\n")))
805 ;; Do not add a link that cannot be resolved and doesn't have
806 ;; any description: destination is already visible in the
807 ;; paragraph.
808 ((not (org-element-contents link)) nil)
810 (concat
811 (org-ascii--fill-string
812 (format "[%s] %s" anchor (org-element-property :raw-link link))
813 width info)
814 "\n\n")))))
815 links ""))
817 (defun org-ascii--checkbox (item info)
818 "Return checkbox string for ITEM or nil.
819 INFO is a plist used as a communication channel."
820 (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
821 (case (org-element-property :checkbox item)
822 (on (if utf8p "☑ " "[X] "))
823 (off (if utf8p "☐ " "[ ] "))
824 (trans (if utf8p "☒ " "[-] ")))))
828 ;;; Template
830 (defun org-ascii-template--document-title (info)
831 "Return document title, as a string.
832 INFO is a plist used as a communication channel."
833 (let* ((text-width org-ascii-text-width)
834 ;; Links in the title will not be resolved later, so we make
835 ;; sure their path is located right after them.
836 (org-ascii-links-to-notes nil)
837 (title (org-export-data (plist-get info :title) info))
838 (author (and (plist-get info :with-author)
839 (let ((auth (plist-get info :author)))
840 (and auth (org-export-data auth info)))))
841 (email (and (plist-get info :with-email)
842 (org-export-data (plist-get info :email) info)))
843 (date (and (plist-get info :with-date)
844 (org-export-data (org-export-get-date info) info))))
845 ;; There are two types of title blocks depending on the presence
846 ;; of a title to display.
847 (if (string= title "")
848 ;; Title block without a title. DATE is positioned at the top
849 ;; right of the document, AUTHOR to the top left and EMAIL
850 ;; just below.
851 (cond
852 ((and (org-string-nw-p date) (org-string-nw-p author))
853 (concat
854 author
855 (make-string (- text-width (length date) (length author)) ? )
856 date
857 (when (org-string-nw-p email) (concat "\n" email))
858 "\n\n\n"))
859 ((and (org-string-nw-p date) (org-string-nw-p email))
860 (concat
861 email
862 (make-string (- text-width (length date) (length email)) ? )
863 date "\n\n\n"))
864 ((org-string-nw-p date)
865 (concat
866 (org-ascii--justify-string date text-width 'right)
867 "\n\n\n"))
868 ((and (org-string-nw-p author) (org-string-nw-p email))
869 (concat author "\n" email "\n\n\n"))
870 ((org-string-nw-p author) (concat author "\n\n\n"))
871 ((org-string-nw-p email) (concat email "\n\n\n")))
872 ;; Title block with a title. Document's TITLE, along with the
873 ;; AUTHOR and its EMAIL are both overlined and an underlined,
874 ;; centered. Date is just below, also centered.
875 (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
876 ;; Format TITLE. It may be filled if it is too wide,
877 ;; that is wider than the two thirds of the total width.
878 (title-len (min (length title) (/ (* 2 text-width) 3)))
879 (formatted-title (org-ascii--fill-string title title-len info))
880 (line
881 (make-string
882 (min (+ (max title-len (length author) (length email)) 2)
883 text-width) (if utf8p ?━ ?_))))
884 (org-ascii--justify-string
885 (concat line "\n"
886 (unless utf8p "\n")
887 (upcase formatted-title)
888 (cond
889 ((and (org-string-nw-p author) (org-string-nw-p email))
890 (concat (if utf8p "\n\n\n" "\n\n") author "\n" email))
891 ((org-string-nw-p author)
892 (concat (if utf8p "\n\n\n" "\n\n") author))
893 ((org-string-nw-p email)
894 (concat (if utf8p "\n\n\n" "\n\n") email)))
895 "\n" line
896 (when (org-string-nw-p date) (concat "\n\n\n" date))
897 "\n\n\n") text-width 'center)))))
899 (defun org-ascii-inner-template (contents info)
900 "Return complete document string after ASCII conversion.
901 CONTENTS is the transcoded contents string. INFO is a plist
902 holding export options."
903 (org-element-normalize-string
904 (org-ascii--indent-string
905 (concat
906 ;; 1. Document's body.
907 contents
908 ;; 2. Footnote definitions.
909 (let ((definitions (org-export-collect-footnote-definitions
910 (plist-get info :parse-tree) info))
911 ;; Insert full links right inside the footnote definition
912 ;; as they have no chance to be inserted later.
913 (org-ascii-links-to-notes nil))
914 (when definitions
915 (concat
916 "\n\n\n"
917 (let ((title (org-ascii--translate "Footnotes" info)))
918 (concat
919 title "\n"
920 (make-string
921 (length title)
922 (if (eq (plist-get info :ascii-charset) 'utf-8) ?─ ?_))))
923 "\n\n"
924 (let ((text-width (- org-ascii-text-width org-ascii-global-margin)))
925 (mapconcat
926 (lambda (ref)
927 (let ((id (format "[%s] " (car ref))))
928 ;; Distinguish between inline definitions and
929 ;; full-fledged definitions.
930 (org-trim
931 (let ((def (nth 2 ref)))
932 (if (eq (org-element-type def) 'org-data)
933 ;; Full-fledged definition: footnote ID is
934 ;; inserted inside the first parsed paragraph
935 ;; (FIRST), if any, to be sure filling will
936 ;; take it into consideration.
937 (let ((first (car (org-element-contents def))))
938 (if (not (eq (org-element-type first) 'paragraph))
939 (concat id "\n" (org-export-data def info))
940 (push id (nthcdr 2 first))
941 (org-export-data def info)))
942 ;; Fill paragraph once footnote ID is inserted
943 ;; in order to have a correct length for first
944 ;; line.
945 (org-ascii--fill-string
946 (concat id (org-export-data def info))
947 text-width info))))))
948 definitions "\n\n"))))))
949 org-ascii-global-margin)))
951 (defun org-ascii-template (contents info)
952 "Return complete document string after ASCII conversion.
953 CONTENTS is the transcoded contents string. INFO is a plist
954 holding export options."
955 (concat
956 ;; 1. Build title block.
957 (org-ascii--indent-string
958 (concat (org-ascii-template--document-title info)
959 ;; 2. Table of contents.
960 (let ((depth (plist-get info :with-toc)))
961 (when depth
962 (concat
963 (org-ascii--build-toc info (and (wholenump depth) depth))
964 "\n\n\n"))))
965 org-ascii-global-margin)
966 ;; 3. Document's body.
967 contents
968 ;; 4. Creator. Ignore `comment' value as there are no comments in
969 ;; ASCII. Justify it to the bottom right.
970 (org-ascii--indent-string
971 (let ((creator-info (plist-get info :with-creator))
972 (text-width (- org-ascii-text-width org-ascii-global-margin)))
973 (unless (or (not creator-info) (eq creator-info 'comment))
974 (concat
975 "\n\n\n"
976 (org-ascii--fill-string
977 (plist-get info :creator) text-width info 'right))))
978 org-ascii-global-margin)))
980 (defun org-ascii--translate (s info)
981 "Translate string S according to specified language and charset.
982 INFO is a plist used as a communication channel."
983 (let ((charset (intern (format ":%s" (plist-get info :ascii-charset)))))
984 (org-export-translate s charset info)))
988 ;;; Transcode Functions
990 ;;;; Bold
992 (defun org-ascii-bold (bold contents info)
993 "Transcode BOLD from Org to ASCII.
994 CONTENTS is the text with bold markup. INFO is a plist holding
995 contextual information."
996 (format "*%s*" contents))
999 ;;;; Center Block
1001 (defun org-ascii-center-block (center-block contents info)
1002 "Transcode a CENTER-BLOCK element from Org to ASCII.
1003 CONTENTS holds the contents of the block. INFO is a plist
1004 holding contextual information."
1005 (org-ascii--justify-string
1006 contents (org-ascii--current-text-width center-block info) 'center))
1009 ;;;; Clock
1011 (defun org-ascii-clock (clock contents info)
1012 "Transcode a CLOCK object from Org to ASCII.
1013 CONTENTS is nil. INFO is a plist holding contextual
1014 information."
1015 (concat org-clock-string " "
1016 (org-translate-time
1017 (org-element-property :raw-value
1018 (org-element-property :value clock)))
1019 (let ((time (org-element-property :duration clock)))
1020 (and time
1021 (concat " => "
1022 (apply 'format
1023 "%2s:%02s"
1024 (org-split-string time ":")))))))
1027 ;;;; Code
1029 (defun org-ascii-code (code contents info)
1030 "Return a CODE object from Org to ASCII.
1031 CONTENTS is nil. INFO is a plist holding contextual
1032 information."
1033 (format org-ascii-verbatim-format (org-element-property :value code)))
1036 ;;;; Drawer
1038 (defun org-ascii-drawer (drawer contents info)
1039 "Transcode a DRAWER element from Org to ASCII.
1040 CONTENTS holds the contents of the block. INFO is a plist
1041 holding contextual information."
1042 (let ((name (org-element-property :drawer-name drawer))
1043 (width (org-ascii--current-text-width drawer info)))
1044 (funcall org-ascii-format-drawer-function name contents width)))
1047 ;;;; Dynamic Block
1049 (defun org-ascii-dynamic-block (dynamic-block contents info)
1050 "Transcode a DYNAMIC-BLOCK element from Org to ASCII.
1051 CONTENTS holds the contents of the block. INFO is a plist
1052 holding contextual information."
1053 contents)
1056 ;;;; Entity
1058 (defun org-ascii-entity (entity contents info)
1059 "Transcode an ENTITY object from Org to ASCII.
1060 CONTENTS are the definition itself. INFO is a plist holding
1061 contextual information."
1062 (org-element-property
1063 (intern (concat ":" (symbol-name (plist-get info :ascii-charset))))
1064 entity))
1067 ;;;; Example Block
1069 (defun org-ascii-example-block (example-block contents info)
1070 "Transcode a EXAMPLE-BLOCK element from Org to ASCII.
1071 CONTENTS is nil. INFO is a plist holding contextual information."
1072 (org-ascii--box-string
1073 (org-export-format-code-default example-block info) info))
1076 ;;;; Export Snippet
1078 (defun org-ascii-export-snippet (export-snippet contents info)
1079 "Transcode a EXPORT-SNIPPET object from Org to ASCII.
1080 CONTENTS is nil. INFO is a plist holding contextual information."
1081 (when (eq (org-export-snippet-backend export-snippet) 'ascii)
1082 (org-element-property :value export-snippet)))
1085 ;;;; Export Block
1087 (defun org-ascii-export-block (export-block contents info)
1088 "Transcode a EXPORT-BLOCK element from Org to ASCII.
1089 CONTENTS is nil. INFO is a plist holding contextual information."
1090 (when (string= (org-element-property :type export-block) "ASCII")
1091 (org-remove-indentation (org-element-property :value export-block))))
1094 ;;;; Fixed Width
1096 (defun org-ascii-fixed-width (fixed-width contents info)
1097 "Transcode a FIXED-WIDTH element from Org to ASCII.
1098 CONTENTS is nil. INFO is a plist holding contextual information."
1099 (org-ascii--box-string
1100 (org-remove-indentation
1101 (org-element-property :value fixed-width)) info))
1104 ;;;; Footnote Definition
1106 ;; Footnote Definitions are ignored. They are compiled at the end of
1107 ;; the document, by `org-ascii-inner-template'.
1110 ;;;; Footnote Reference
1112 (defun org-ascii-footnote-reference (footnote-reference contents info)
1113 "Transcode a FOOTNOTE-REFERENCE element from Org to ASCII.
1114 CONTENTS is nil. INFO is a plist holding contextual information."
1115 (format "[%s]" (org-export-get-footnote-number footnote-reference info)))
1118 ;;;; Headline
1120 (defun org-ascii-headline (headline contents info)
1121 "Transcode a HEADLINE element from Org to ASCII.
1122 CONTENTS holds the contents of the headline. INFO is a plist
1123 holding contextual information."
1124 ;; Don't export footnote section, which will be handled at the end
1125 ;; of the template.
1126 (unless (org-element-property :footnote-section-p headline)
1127 (let* ((low-level-rank (org-export-low-level-p headline info))
1128 (width (org-ascii--current-text-width headline info))
1129 ;; Blank lines between headline and its contents.
1130 ;; `org-ascii-headline-spacing', when set, overwrites
1131 ;; original buffer's spacing.
1132 (pre-blanks
1133 (make-string
1134 (if org-ascii-headline-spacing (car org-ascii-headline-spacing)
1135 (org-element-property :pre-blank headline)) ?\n))
1136 ;; Even if HEADLINE has no section, there might be some
1137 ;; links in its title that we shouldn't forget to describe.
1138 (links
1139 (unless (or (eq (caar (org-element-contents headline)) 'section))
1140 (let ((title (org-element-property :title headline)))
1141 (when (consp title)
1142 (org-ascii--describe-links
1143 (org-ascii--unique-links title info) width info))))))
1144 ;; Deep subtree: export it as a list item.
1145 (if low-level-rank
1146 (concat
1147 ;; Bullet.
1148 (let ((bullets (cdr (assq (plist-get info :ascii-charset)
1149 org-ascii-bullets))))
1150 (char-to-string
1151 (nth (mod (1- low-level-rank) (length bullets)) bullets)))
1153 ;; Title.
1154 (org-ascii--build-title headline info width) "\n"
1155 ;; Contents, indented by length of bullet.
1156 pre-blanks
1157 (org-ascii--indent-string
1158 (concat contents
1159 (when (org-string-nw-p links) (concat "\n\n" links)))
1161 ;; Else: Standard headline.
1162 (concat
1163 (org-ascii--build-title headline info width 'underline)
1164 "\n" pre-blanks
1165 (concat (when (org-string-nw-p links) links) contents))))))
1168 ;;;; Horizontal Rule
1170 (defun org-ascii-horizontal-rule (horizontal-rule contents info)
1171 "Transcode an HORIZONTAL-RULE object from Org to ASCII.
1172 CONTENTS is nil. INFO is a plist holding contextual
1173 information."
1174 (let ((text-width (org-ascii--current-text-width horizontal-rule info))
1175 (spec-width
1176 (org-export-read-attribute :attr_ascii horizontal-rule :width)))
1177 (org-ascii--justify-string
1178 (make-string (if (and spec-width (string-match "^[0-9]+$" spec-width))
1179 (string-to-number spec-width)
1180 text-width)
1181 (if (eq (plist-get info :ascii-charset) 'utf-8) ?― ?-))
1182 text-width 'center)))
1185 ;;;; Inline Src Block
1187 (defun org-ascii-inline-src-block (inline-src-block contents info)
1188 "Transcode an INLINE-SRC-BLOCK element from Org to ASCII.
1189 CONTENTS holds the contents of the item. INFO is a plist holding
1190 contextual information."
1191 (format org-ascii-verbatim-format
1192 (org-element-property :value inline-src-block)))
1195 ;;;; Inlinetask
1197 (defun org-ascii-format-inlinetask-default
1198 (todo type priority name tags contents width inlinetask info)
1199 "Format an inline task element for ASCII export.
1200 See `org-ascii-format-inlinetask-function' for a description
1201 of the parameters."
1202 (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
1203 (width (or width org-ascii-inlinetask-width)))
1204 (org-ascii--indent-string
1205 (concat
1206 ;; Top line, with an additional blank line if not in UTF-8.
1207 (make-string width (if utf8p ?━ ?_)) "\n"
1208 (unless utf8p (concat (make-string width ? ) "\n"))
1209 ;; Add title. Fill it if wider than inlinetask.
1210 (let ((title (org-ascii--build-title inlinetask info width)))
1211 (if (<= (length title) width) title
1212 (org-ascii--fill-string title width info)))
1213 "\n"
1214 ;; If CONTENTS is not empty, insert it along with
1215 ;; a separator.
1216 (when (org-string-nw-p contents)
1217 (concat (make-string width (if utf8p ?─ ?-)) "\n" contents))
1218 ;; Bottom line.
1219 (make-string width (if utf8p ?━ ?_)))
1220 ;; Flush the inlinetask to the right.
1221 (- org-ascii-text-width org-ascii-global-margin
1222 (if (not (org-export-get-parent-headline inlinetask)) 0
1223 org-ascii-inner-margin)
1224 (org-ascii--current-text-width inlinetask info)))))
1226 (defun org-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-ascii--current-text-width inlinetask info)))
1231 (funcall org-ascii-format-inlinetask-function
1232 ;; todo.
1233 (and (plist-get info :with-todo-keywords)
1234 (let ((todo (org-element-property
1235 :todo-keyword inlinetask)))
1236 (and todo (org-export-data todo info))))
1237 ;; todo-type
1238 (org-element-property :todo-type inlinetask)
1239 ;; priority
1240 (and (plist-get info :with-priority)
1241 (org-element-property :priority inlinetask))
1242 ;; title
1243 (org-export-data (org-element-property :title inlinetask) info)
1244 ;; tags
1245 (and (plist-get info :with-tags)
1246 (org-element-property :tags inlinetask))
1247 ;; contents and width
1248 contents width inlinetask info)))
1251 ;;;; Italic
1253 (defun org-ascii-italic (italic contents info)
1254 "Transcode italic from Org to ASCII.
1255 CONTENTS is the text with italic markup. INFO is a plist holding
1256 contextual information."
1257 (format "/%s/" contents))
1260 ;;;; Item
1262 (defun org-ascii-item (item contents info)
1263 "Transcode an ITEM element from Org to ASCII.
1264 CONTENTS holds the contents of the item. INFO is a plist holding
1265 contextual information."
1266 (let* ((utf8p (eq (plist-get info :ascii-charset) 'utf-8))
1267 (checkbox (org-ascii--checkbox item info))
1268 (list-type (org-element-property :type (org-export-get-parent item)))
1269 (bullet
1270 ;; First parent of ITEM is always the plain-list. Get
1271 ;; `:type' property from it.
1272 (org-list-bullet-string
1273 (case list-type
1274 (descriptive
1275 (concat checkbox
1276 (org-export-data (org-element-property :tag item) info)
1277 ": "))
1278 (ordered
1279 ;; Return correct number for ITEM, paying attention to
1280 ;; counters.
1281 (let* ((struct (org-element-property :structure item))
1282 (bul (org-element-property :bullet item))
1283 (num (number-to-string
1284 (car (last (org-list-get-item-number
1285 (org-element-property :begin item)
1286 struct
1287 (org-list-prevs-alist struct)
1288 (org-list-parents-alist struct)))))))
1289 (replace-regexp-in-string "[0-9]+" num bul)))
1290 (t (let ((bul (org-element-property :bullet item)))
1291 ;; Change bullets into more visible form if UTF-8 is active.
1292 (if (not utf8p) bul
1293 (replace-regexp-in-string
1294 "-" "•"
1295 (replace-regexp-in-string
1296 "+" "⁃"
1297 (replace-regexp-in-string "*" "‣" bul))))))))))
1298 (concat
1299 bullet
1300 (unless (eq list-type 'descriptive) checkbox)
1301 ;; Contents: Pay attention to indentation. Note: check-boxes are
1302 ;; already taken care of at the paragraph level so they don't
1303 ;; interfere with indentation.
1304 (let ((contents (org-ascii--indent-string contents (length bullet))))
1305 (if (eq (org-element-type (car (org-element-contents item))) 'paragraph)
1306 (org-trim contents)
1307 (concat "\n" contents))))))
1310 ;;;; Keyword
1312 (defun org-ascii-keyword (keyword contents info)
1313 "Transcode a KEYWORD element from Org to ASCII.
1314 CONTENTS is nil. INFO is a plist holding contextual
1315 information."
1316 (let ((key (org-element-property :key keyword))
1317 (value (org-element-property :value keyword)))
1318 (cond
1319 ((string= key "ASCII") value)
1320 ((string= key "TOC")
1321 (let ((value (downcase value)))
1322 (cond
1323 ((string-match "\\<headlines\\>" value)
1324 (let ((depth (or (and (string-match "[0-9]+" value)
1325 (string-to-number (match-string 0 value)))
1326 (plist-get info :with-toc))))
1327 (org-ascii--build-toc
1328 info (and (wholenump depth) depth) keyword)))
1329 ((string= "tables" value)
1330 (org-ascii--list-tables keyword info))
1331 ((string= "listings" value)
1332 (org-ascii--list-listings keyword info))))))))
1335 ;;;; Latex Environment
1337 (defun org-ascii-latex-environment (latex-environment contents info)
1338 "Transcode a LATEX-ENVIRONMENT element from Org to ASCII.
1339 CONTENTS is nil. INFO is a plist holding contextual
1340 information."
1341 (when (plist-get info :with-latex)
1342 (org-remove-indentation (org-element-property :value latex-environment))))
1345 ;;;; Latex Fragment
1347 (defun org-ascii-latex-fragment (latex-fragment contents info)
1348 "Transcode a LATEX-FRAGMENT object from Org to ASCII.
1349 CONTENTS is nil. INFO is a plist holding contextual
1350 information."
1351 (when (plist-get info :with-latex)
1352 (org-element-property :value latex-fragment)))
1355 ;;;; Line Break
1357 (defun org-ascii-line-break (line-break contents info)
1358 "Transcode a LINE-BREAK object from Org to ASCII.
1359 CONTENTS is nil. INFO is a plist holding contextual
1360 information." hard-newline)
1363 ;;;; Link
1365 (defun org-ascii-link (link desc info)
1366 "Transcode a LINK object from Org to ASCII.
1368 DESC is the description part of the link, or the empty string.
1369 INFO is a plist holding contextual information."
1370 (let ((raw-link (org-element-property :raw-link link))
1371 (type (org-element-property :type link)))
1372 (cond
1373 ((string= type "coderef")
1374 (let ((ref (org-element-property :path link)))
1375 (format (org-export-get-coderef-format ref desc)
1376 (org-export-resolve-coderef ref info))))
1377 ;; Do not apply a special syntax on radio links. Though, use
1378 ;; transcoded target's contents as output.
1379 ((string= type "radio")
1380 (let ((destination (org-export-resolve-radio-link link info)))
1381 (when destination
1382 (org-export-data (org-element-contents destination) info))))
1383 ;; Do not apply a special syntax on fuzzy links pointing to
1384 ;; targets.
1385 ((string= type "fuzzy")
1386 (let ((destination (org-export-resolve-fuzzy-link link info)))
1387 (if (org-string-nw-p desc) desc
1388 (when destination
1389 (let ((number
1390 (org-export-get-ordinal
1391 destination info nil 'org-ascii--has-caption-p)))
1392 (when number
1393 (if (atom number) (number-to-string number)
1394 (mapconcat 'number-to-string number "."))))))))
1396 (if (not (org-string-nw-p desc)) (format "[%s]" raw-link)
1397 (concat
1398 (format "[%s]" desc)
1399 (unless org-ascii-links-to-notes (format " (%s)" raw-link))))))))
1402 ;;;; Paragraph
1404 (defun org-ascii-paragraph (paragraph contents info)
1405 "Transcode a PARAGRAPH element from Org to ASCII.
1406 CONTENTS is the contents of the paragraph, as a string. INFO is
1407 the plist used as a communication channel."
1408 (let ((contents (if (not (wholenump org-ascii-indented-line-width)) contents
1409 (concat
1410 (make-string org-ascii-indented-line-width ? )
1411 (replace-regexp-in-string "\\`[ \t]+" "" contents)))))
1412 (org-ascii--fill-string
1413 contents (org-ascii--current-text-width paragraph info) info)))
1416 ;;;; Plain List
1418 (defun org-ascii-plain-list (plain-list contents info)
1419 "Transcode a PLAIN-LIST element from Org to ASCII.
1420 CONTENTS is the contents of the list. INFO is a plist holding
1421 contextual information."
1422 contents)
1425 ;;;; Plain Text
1427 (defun org-ascii-plain-text (text info)
1428 "Transcode a TEXT string from Org to ASCII.
1429 INFO is a plist used as a communication channel."
1430 (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
1431 (when (and utf8p (plist-get info :with-smart-quotes))
1432 (setq text (org-export-activate-smart-quotes text :utf-8 info)))
1433 (if (not (plist-get info :with-special-strings)) text
1434 (setq text (replace-regexp-in-string "\\\\-" "" text))
1435 (if (not utf8p) text
1436 ;; Usual replacements in utf-8 with proper option set.
1437 (replace-regexp-in-string
1438 "\\.\\.\\." "…"
1439 (replace-regexp-in-string
1440 "--" "–"
1441 (replace-regexp-in-string "---" "—" text)))))))
1444 ;;;; Planning
1446 (defun org-ascii-planning (planning contents info)
1447 "Transcode a PLANNING element from Org to ASCII.
1448 CONTENTS is nil. INFO is a plist used as a communication
1449 channel."
1450 (mapconcat
1451 'identity
1452 (delq nil
1453 (list (let ((closed (org-element-property :closed planning)))
1454 (when closed
1455 (concat org-closed-string " "
1456 (org-translate-time
1457 (org-element-property :raw-value closed)))))
1458 (let ((deadline (org-element-property :deadline planning)))
1459 (when deadline
1460 (concat org-deadline-string " "
1461 (org-translate-time
1462 (org-element-property :raw-value deadline)))))
1463 (let ((scheduled (org-element-property :scheduled planning)))
1464 (when scheduled
1465 (concat org-scheduled-string " "
1466 (org-translate-time
1467 (org-element-property :raw-value scheduled)))))))
1468 " "))
1471 ;;;; Quote Block
1473 (defun org-ascii-quote-block (quote-block contents info)
1474 "Transcode a QUOTE-BLOCK element from Org to ASCII.
1475 CONTENTS holds the contents of the block. INFO is a plist
1476 holding contextual information."
1477 (org-ascii--indent-string contents org-ascii-quote-margin))
1480 ;;;; Quote Section
1482 (defun org-ascii-quote-section (quote-section contents info)
1483 "Transcode a QUOTE-SECTION element from Org to ASCII.
1484 CONTENTS is nil. INFO is a plist holding contextual information."
1485 (let ((width (org-ascii--current-text-width quote-section info))
1486 (value
1487 (org-export-data
1488 (org-remove-indentation (org-element-property :value quote-section))
1489 info)))
1490 (org-ascii--indent-string
1491 value
1492 (+ org-ascii-quote-margin
1493 ;; Don't apply inner margin if parent headline is low level.
1494 (let ((headline (org-export-get-parent-headline quote-section)))
1495 (if (org-export-low-level-p headline info) 0
1496 org-ascii-inner-margin))))))
1499 ;;;; Radio Target
1501 (defun org-ascii-radio-target (radio-target contents info)
1502 "Transcode a RADIO-TARGET object from Org to ASCII.
1503 CONTENTS is the contents of the target. INFO is a plist holding
1504 contextual information."
1505 contents)
1508 ;;;; Section
1510 (defun org-ascii-section (section contents info)
1511 "Transcode a SECTION element from Org to ASCII.
1512 CONTENTS is the contents of the section. INFO is a plist holding
1513 contextual information."
1514 (org-ascii--indent-string
1515 (concat
1516 contents
1517 (when org-ascii-links-to-notes
1518 ;; Add list of links at the end of SECTION.
1519 (let ((links (org-ascii--describe-links
1520 (org-ascii--unique-links section info)
1521 (org-ascii--current-text-width section info) info)))
1522 ;; Separate list of links and section contents.
1523 (when (org-string-nw-p links) (concat "\n\n" links)))))
1524 ;; Do not apply inner margin if parent headline is low level.
1525 (let ((headline (org-export-get-parent-headline section)))
1526 (if (or (not headline) (org-export-low-level-p headline info)) 0
1527 org-ascii-inner-margin))))
1530 ;;;; Special Block
1532 (defun org-ascii-special-block (special-block contents info)
1533 "Transcode a SPECIAL-BLOCK element from Org to ASCII.
1534 CONTENTS holds the contents of the block. INFO is a plist
1535 holding contextual information."
1536 contents)
1539 ;;;; Src Block
1541 (defun org-ascii-src-block (src-block contents info)
1542 "Transcode a SRC-BLOCK element from Org to ASCII.
1543 CONTENTS holds the contents of the item. INFO is a plist holding
1544 contextual information."
1545 (let ((caption (org-ascii--build-caption src-block info))
1546 (code (org-export-format-code-default src-block info)))
1547 (if (equal code "") ""
1548 (concat
1549 (when (and caption org-ascii-caption-above) (concat caption "\n"))
1550 (org-ascii--box-string code info)
1551 (when (and caption (not org-ascii-caption-above))
1552 (concat "\n" caption))))))
1555 ;;;; Statistics Cookie
1557 (defun org-ascii-statistics-cookie (statistics-cookie contents info)
1558 "Transcode a STATISTICS-COOKIE object from Org to ASCII.
1559 CONTENTS is nil. INFO is a plist holding contextual information."
1560 (org-element-property :value statistics-cookie))
1563 ;;;; Subscript
1565 (defun org-ascii-subscript (subscript contents info)
1566 "Transcode a SUBSCRIPT object from Org to ASCII.
1567 CONTENTS is the contents of the object. INFO is a plist holding
1568 contextual information."
1569 (if (org-element-property :use-brackets-p subscript)
1570 (format "_{%s}" contents)
1571 (format "_%s" contents)))
1574 ;;;; Superscript
1576 (defun org-ascii-superscript (superscript contents info)
1577 "Transcode a SUPERSCRIPT object from Org to ASCII.
1578 CONTENTS is the contents of the object. INFO is a plist holding
1579 contextual information."
1580 (if (org-element-property :use-brackets-p superscript)
1581 (format "_{%s}" contents)
1582 (format "_%s" contents)))
1585 ;;;; Strike-through
1587 (defun org-ascii-strike-through (strike-through contents info)
1588 "Transcode STRIKE-THROUGH from Org to ASCII.
1589 CONTENTS is text with strike-through markup. INFO is a plist
1590 holding contextual information."
1591 (format "+%s+" contents))
1594 ;;;; Table
1596 (defun org-ascii-table (table contents info)
1597 "Transcode a TABLE element from Org to ASCII.
1598 CONTENTS is the contents of the table. INFO is a plist holding
1599 contextual information."
1600 (let ((caption (org-ascii--build-caption table info)))
1601 (concat
1602 ;; Possibly add a caption string above.
1603 (when (and caption org-ascii-caption-above) (concat caption "\n"))
1604 ;; Insert table. Note: "table.el" tables are left unmodified.
1605 (cond ((eq (org-element-property :type table) 'org) contents)
1606 ((and org-ascii-table-use-ascii-art
1607 (eq (plist-get info :ascii-charset) 'utf-8)
1608 (require 'ascii-art-to-unicode nil t))
1609 (with-temp-buffer
1610 (insert (org-remove-indentation
1611 (org-element-property :value table)))
1612 (goto-char (point-min))
1613 (aa2u)
1614 (goto-char (point-max))
1615 (skip-chars-backward " \r\t\n")
1616 (buffer-substring (point-min) (point))))
1617 (t (org-remove-indentation (org-element-property :value table))))
1618 ;; Possible add a caption string below.
1619 (and (not org-ascii-caption-above) caption))))
1622 ;;;; Table Cell
1624 (defun org-ascii--table-cell-width (table-cell info)
1625 "Return width of TABLE-CELL.
1627 INFO is a plist used as a communication channel.
1629 Width of a cell is determined either by a width cookie in the
1630 same column as the cell, or by the maximum cell's length in that
1631 column.
1633 When `org-ascii-table-widen-columns' is non-nil, width cookies
1634 are ignored."
1635 (let* ((row (org-export-get-parent table-cell))
1636 (table (org-export-get-parent row))
1637 (col (let ((cells (org-element-contents row)))
1638 (- (length cells) (length (memq table-cell cells)))))
1639 (cache
1640 (or (plist-get info :ascii-table-cell-width-cache)
1641 (plist-get (setq info
1642 (plist-put info :ascii-table-cell-width-cache
1643 (make-hash-table :test 'equal)))
1644 :ascii-table-cell-width-cache)))
1645 (key (cons table col)))
1646 (or (gethash key cache)
1647 (puthash
1649 (or (and (not org-ascii-table-widen-columns)
1650 (org-export-table-cell-width table-cell info))
1651 (let* ((max-width 0))
1652 (org-element-map table 'table-row
1653 (lambda (row)
1654 (setq max-width
1655 (max (length
1656 (org-export-data
1657 (org-element-contents
1658 (elt (org-element-contents row) col))
1659 info))
1660 max-width)))
1661 info)
1662 max-width))
1663 cache))))
1665 (defun org-ascii-table-cell (table-cell contents info)
1666 "Transcode a TABLE-CELL object from Org to ASCII.
1667 CONTENTS is the cell contents. INFO is a plist used as
1668 a communication channel."
1669 ;; Determine column width. When `org-ascii-table-widen-columns'
1670 ;; is nil and some width cookie has set it, use that value.
1671 ;; Otherwise, compute the maximum width among transcoded data of
1672 ;; each cell in the column.
1673 (let ((width (org-ascii--table-cell-width table-cell info)))
1674 ;; When contents are too large, truncate them.
1675 (unless (or org-ascii-table-widen-columns (<= (length contents) width))
1676 (setq contents (concat (substring contents 0 (- width 2)) "=>")))
1677 ;; Align contents correctly within the cell.
1678 (let* ((indent-tabs-mode nil)
1679 (data
1680 (when contents
1681 (org-ascii--justify-string
1682 contents width
1683 (org-export-table-cell-alignment table-cell info)))))
1684 (setq contents (concat data (make-string (- width (length data)) ? ))))
1685 ;; Return cell.
1686 (concat (format " %s " contents)
1687 (when (memq 'right (org-export-table-cell-borders table-cell info))
1688 (if (eq (plist-get info :ascii-charset) 'utf-8) "│" "|")))))
1691 ;;;; Table Row
1693 (defun org-ascii-table-row (table-row contents info)
1694 "Transcode a TABLE-ROW element from Org to ASCII.
1695 CONTENTS is the row contents. INFO is a plist used as
1696 a communication channel."
1697 (when (eq (org-element-property :type table-row) 'standard)
1698 (let ((build-hline
1699 (function
1700 (lambda (lcorner horiz vert rcorner)
1701 (concat
1702 (apply
1703 'concat
1704 (org-element-map table-row 'table-cell
1705 (lambda (cell)
1706 (let ((width (org-ascii--table-cell-width cell info))
1707 (borders (org-export-table-cell-borders cell info)))
1708 (concat
1709 ;; In order to know if CELL starts the row, do
1710 ;; not compare it with the first cell in the
1711 ;; row as there might be a special column.
1712 ;; Instead, compare it with first exportable
1713 ;; cell, obtained with `org-element-map'.
1714 (when (and (memq 'left borders)
1715 (eq (org-element-map table-row 'table-cell
1716 'identity info t)
1717 cell))
1718 lcorner)
1719 (make-string (+ 2 width) (string-to-char horiz))
1720 (cond
1721 ((not (memq 'right borders)) nil)
1722 ((eq (car (last (org-element-contents table-row))) cell)
1723 rcorner)
1724 (t vert)))))
1725 info)) "\n"))))
1726 (utf8p (eq (plist-get info :ascii-charset) 'utf-8))
1727 (borders (org-export-table-cell-borders
1728 (org-element-map table-row 'table-cell 'identity info t)
1729 info)))
1730 (concat (cond
1731 ((and (memq 'top borders) (or utf8p (memq 'above borders)))
1732 (if utf8p (funcall build-hline "┍" "━" "┯" "┑")
1733 (funcall build-hline "+" "-" "+" "+")))
1734 ((memq 'above borders)
1735 (if utf8p (funcall build-hline "├" "─" "┼" "┤")
1736 (funcall build-hline "+" "-" "+" "+"))))
1737 (when (memq 'left borders) (if utf8p "│" "|"))
1738 contents "\n"
1739 (when (and (memq 'bottom borders) (or utf8p (memq 'below borders)))
1740 (if utf8p (funcall build-hline "┕" "━" "┷" "┙")
1741 (funcall build-hline "+" "-" "+" "+")))))))
1744 ;;;; Timestamp
1746 (defun org-ascii-timestamp (timestamp contents info)
1747 "Transcode a TIMESTAMP object from Org to ASCII.
1748 CONTENTS is nil. INFO is a plist holding contextual information."
1749 (org-ascii-plain-text (org-timestamp-translate timestamp) info))
1752 ;;;; Underline
1754 (defun org-ascii-underline (underline contents info)
1755 "Transcode UNDERLINE from Org to ASCII.
1756 CONTENTS is the text with underline markup. INFO is a plist
1757 holding contextual information."
1758 (format "_%s_" contents))
1761 ;;;; Verbatim
1763 (defun org-ascii-verbatim (verbatim contents info)
1764 "Return a VERBATIM object from Org to ASCII.
1765 CONTENTS is nil. INFO is a plist holding contextual information."
1766 (format org-ascii-verbatim-format
1767 (org-element-property :value verbatim)))
1770 ;;;; Verse Block
1772 (defun org-ascii-verse-block (verse-block contents info)
1773 "Transcode a VERSE-BLOCK element from Org to ASCII.
1774 CONTENTS is verse block contents. INFO is a plist holding
1775 contextual information."
1776 (let ((verse-width (org-ascii--current-text-width verse-block info)))
1777 (org-ascii--indent-string
1778 (org-ascii--justify-string contents verse-width 'left)
1779 org-ascii-quote-margin)))
1783 ;;; Filters
1785 (defun org-ascii-filter-headline-blank-lines (headline back-end info)
1786 "Filter controlling number of blank lines after a headline.
1788 HEADLINE is a string representing a transcoded headline.
1789 BACK-END is symbol specifying back-end used for export. INFO is
1790 plist containing the communication channel.
1792 This function only applies to `ascii' back-end. See
1793 `org-ascii-headline-spacing' for information."
1794 (if (not org-ascii-headline-spacing) headline
1795 (let ((blanks (make-string (1+ (cdr org-ascii-headline-spacing)) ?\n)))
1796 (replace-regexp-in-string "\n\\(?:\n[ \t]*\\)*\\'" blanks headline))))
1798 (defun org-ascii-filter-paragraph-spacing (tree back-end info)
1799 "Filter controlling number of blank lines between paragraphs.
1801 TREE is the parse tree. BACK-END is the symbol specifying
1802 back-end used for export. INFO is a plist used as
1803 a communication channel.
1805 See `org-ascii-paragraph-spacing' for information."
1806 (when (wholenump org-ascii-paragraph-spacing)
1807 (org-element-map tree 'paragraph
1808 (lambda (p)
1809 (when (eq (org-element-type (org-export-get-next-element p info))
1810 'paragraph)
1811 (org-element-put-property
1812 p :post-blank org-ascii-paragraph-spacing)))))
1813 tree)
1815 (defun org-ascii-filter-comment-spacing (tree backend info)
1816 "Filter removing blank lines between comments.
1817 TREE is the parse tree. BACK-END is the symbol specifying
1818 back-end used for export. INFO is a plist used as
1819 a communication channel."
1820 (org-element-map tree '(comment comment-block)
1821 (lambda (c)
1822 (when (memq (org-element-type (org-export-get-next-element c info))
1823 '(comment comment-block))
1824 (org-element-put-property c :post-blank 0))))
1825 tree)
1829 ;;; End-user functions
1831 ;;;###autoload
1832 (defun org-ascii-export-as-ascii
1833 (&optional async subtreep visible-only body-only ext-plist)
1834 "Export current buffer to a text buffer.
1836 If narrowing is active in the current buffer, only export its
1837 narrowed part.
1839 If a region is active, export that region.
1841 A non-nil optional argument ASYNC means the process should happen
1842 asynchronously. The resulting buffer should be accessible
1843 through the `org-export-stack' interface.
1845 When optional argument SUBTREEP is non-nil, export the sub-tree
1846 at point, extracting information from the headline properties
1847 first.
1849 When optional argument VISIBLE-ONLY is non-nil, don't export
1850 contents of hidden elements.
1852 When optional argument BODY-ONLY is non-nil, strip title and
1853 table of contents from output.
1855 EXT-PLIST, when provided, is a property list with external
1856 parameters overriding Org default settings, but still inferior to
1857 file-local settings.
1859 Export is done in a buffer named \"*Org ASCII Export*\", which
1860 will be displayed when `org-export-show-temporary-export-buffer'
1861 is non-nil."
1862 (interactive)
1863 (org-export-to-buffer 'ascii "*Org ASCII Export*"
1864 async subtreep visible-only body-only ext-plist (lambda () (text-mode))))
1866 ;;;###autoload
1867 (defun org-ascii-export-to-ascii
1868 (&optional async subtreep visible-only body-only ext-plist)
1869 "Export current buffer to a text file.
1871 If narrowing is active in the current buffer, only export its
1872 narrowed part.
1874 If a region is active, export that region.
1876 A non-nil optional argument ASYNC means the process should happen
1877 asynchronously. The resulting file should be accessible through
1878 the `org-export-stack' interface.
1880 When optional argument SUBTREEP is non-nil, export the sub-tree
1881 at point, extracting information from the headline properties
1882 first.
1884 When optional argument VISIBLE-ONLY is non-nil, don't export
1885 contents of hidden elements.
1887 When optional argument BODY-ONLY is non-nil, strip title and
1888 table of contents from output.
1890 EXT-PLIST, when provided, is a property list with external
1891 parameters overriding Org default settings, but still inferior to
1892 file-local settings.
1894 Return output file's name."
1895 (interactive)
1896 (let ((file (org-export-output-file-name ".txt" subtreep)))
1897 (org-export-to-file 'ascii file
1898 async subtreep visible-only body-only ext-plist)))
1900 ;;;###autoload
1901 (defun org-ascii-publish-to-ascii (plist filename pub-dir)
1902 "Publish an Org file to ASCII.
1904 FILENAME is the filename of the Org file to be published. PLIST
1905 is the property list for the given project. PUB-DIR is the
1906 publishing directory.
1908 Return output file name."
1909 (org-publish-org-to
1910 'ascii filename ".txt" `(:ascii-charset ascii ,@plist) pub-dir))
1912 ;;;###autoload
1913 (defun org-ascii-publish-to-latin1 (plist filename pub-dir)
1914 "Publish an Org file to Latin-1.
1916 FILENAME is the filename of the Org file to be published. PLIST
1917 is the property list for the given project. PUB-DIR is the
1918 publishing directory.
1920 Return output file name."
1921 (org-publish-org-to
1922 'ascii filename ".txt" `(:ascii-charset latin1 ,@plist) pub-dir))
1924 ;;;###autoload
1925 (defun org-ascii-publish-to-utf8 (plist filename pub-dir)
1926 "Publish an org file to UTF-8.
1928 FILENAME is the filename of the Org file to be published. PLIST
1929 is the property list for the given project. PUB-DIR is the
1930 publishing directory.
1932 Return output file name."
1933 (org-publish-org-to
1934 'ascii filename ".txt" `(:ascii-charset utf-8 ,@plist) pub-dir))
1937 (provide 'ox-ascii)
1939 ;; Local variables:
1940 ;; generated-autoload-file: "org-loaddefs.el"
1941 ;; coding: utf-8-emacs
1942 ;; End:
1944 ;;; ox-ascii.el ends here