1 ;;; org-ascii.el --- ASCII export for Org-mode
3 ;; Copyright (C) 2004-2013 Free Software Foundation, Inc.
5 ;; Author: Carsten Dominik <carsten at orgmode dot org>
6 ;; Keywords: outlines, hypermedia, calendar, wp
7 ;; Homepage: http://orgmode.org
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 (defgroup org-export-ascii nil
35 "Options specific for ASCII export of Org-mode files."
36 :tag
"Org Export ASCII"
39 (defcustom org-export-ascii-underline
'(?\
= ?\- ?\~ ?\^ ?\. ?\
# ?\$
)
40 "Characters for underlining headings in ASCII export.
41 In the given sequence, these characters will be used for level 1, 2, ..."
42 :group
'org-export-ascii
43 :type
'(repeat character
))
45 (defcustom org-export-ascii-bullets
'(?
* ?
+ ?-
)
46 "Bullet characters for headlines converted to lists in ASCII export.
47 The first character is used for the first lest level generated in this
48 way, and so on. If there are more levels than characters given here,
49 the list will be repeated.
50 Note that plain lists will keep the same bullets as the have in the
52 :group
'org-export-ascii
53 :type
'(repeat character
))
55 (defcustom org-export-ascii-links-to-notes t
56 "Non-nil means convert links to notes before the next headline.
57 When nil, the link will be exported in place. If the line becomes long
58 in this way, it will be wrapped."
59 :group
'org-export-ascii
62 (defcustom org-export-ascii-table-keep-all-vertical-lines nil
63 "Non-nil means keep all vertical lines in ASCII tables.
64 When nil, vertical lines will be removed except for those needed
66 :group
'org-export-ascii
69 (defcustom org-export-ascii-table-widen-columns t
70 "Non-nil means widen narrowed columns for export.
71 When nil, narrowed columns will look in ASCII export just like in org-mode,
72 i.e. with \"=>\" as ellipsis."
73 :group
'org-export-ascii
76 (defvar org-export-ascii-entities
'ascii
77 "The ascii representation to be used during ascii export.
80 ascii Only use plain ASCII characters
81 latin1 Include Latin-1 character
82 utf8 Use all UTF-8 characters")
86 (defvar org-export-ascii-final-hook nil
87 "Hook run at the end of ASCII export, in the new buffer.")
91 (defvar org-ascii-current-indentation nil
) ; For communication
94 (defun org-export-as-latin1 (&rest args
)
95 "Like `org-export-as-ascii', use latin1 encoding for special symbols."
97 (org-export-as-encoding 'org-export-as-ascii
(org-called-interactively-p 'any
)
101 (defun org-export-as-latin1-to-buffer (&rest args
)
102 "Like `org-export-as-ascii-to-buffer', use latin1 encoding for symbols."
104 (org-export-as-encoding 'org-export-as-ascii-to-buffer
105 (org-called-interactively-p 'any
) 'latin1 args
))
108 (defun org-export-as-utf8 (&rest args
)
109 "Like `org-export-as-ascii', use encoding for special symbols."
111 (org-export-as-encoding 'org-export-as-ascii
112 (org-called-interactively-p 'any
)
116 (defun org-export-as-utf8-to-buffer (&rest args
)
117 "Like `org-export-as-ascii-to-buffer', use utf8 encoding for symbols."
119 (org-export-as-encoding 'org-export-as-ascii-to-buffer
120 (org-called-interactively-p 'any
) 'utf8 args
))
122 (defun org-export-as-encoding (command interactivep encoding
&rest args
)
123 (let ((org-export-ascii-entities encoding
))
125 (call-interactively command
)
126 (apply command args
))))
130 (defun org-export-as-ascii-to-buffer (arg)
131 "Call `org-export-as-ascii` with output to a temporary buffer.
132 No file is created. The prefix ARG is passed through to `org-export-as-ascii'."
134 (org-export-as-ascii arg nil
"*Org ASCII Export*")
135 (when org-export-show-temporary-export-buffer
136 (switch-to-buffer-other-window "*Org ASCII Export*")))
139 (defun org-replace-region-by-ascii (beg end
)
140 "Assume the current region has org-mode syntax, and convert it to plain ASCII.
141 This can be used in any buffer. For example, you could write an
142 itemized list in org-mode syntax in a Mail buffer and then use this
143 command to convert it."
145 (let (reg ascii buf pop-up-frames
)
146 (save-window-excursion
147 (if (derived-mode-p 'org-mode
)
148 (setq ascii
(org-export-region-as-ascii
150 (setq reg
(buffer-substring beg end
)
151 buf
(get-buffer-create "*Org tmp*"))
152 (with-current-buffer buf
156 (setq ascii
(org-export-region-as-ascii
157 (point-min) (point-max) t
'string
)))
159 (delete-region beg end
)
163 (defun org-export-region-as-ascii (beg end
&optional body-only buffer
)
164 "Convert region from BEG to END in org-mode buffer to plain ASCII.
165 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
166 contents, and only produce the region of converted text, useful for
167 cut-and-paste operations.
168 If BUFFER is a buffer or a string, use/create that buffer as a target
169 of the converted ASCII. If BUFFER is the symbol `string', return the
170 produced ASCII as a string and leave not buffer behind. For example,
171 a Lisp program could call this function in the following way:
173 (setq ascii (org-export-region-as-ascii beg end t 'string))
175 When called interactively, the output buffer is selected, and shown
176 in a window. A non-interactive call will only return the buffer."
178 (when (org-called-interactively-p 'any
)
179 (setq buffer
"*Org ASCII Export*"))
180 (let ((transient-mark-mode t
) (zmacs-regions t
)
182 (setq ext-plist
(plist-put ext-plist
:ignore-subtree-p t
))
184 (set-mark (point)) ;; to activate the region
186 (setq rtn
(org-export-as-ascii nil ext-plist buffer body-only
))
187 (if (fboundp 'deactivate-mark
) (deactivate-mark))
188 (if (and (org-called-interactively-p 'any
) (bufferp rtn
))
189 (switch-to-buffer-other-window rtn
)
193 (defun org-export-as-ascii (arg &optional ext-plist to-buffer body-only pub-dir
)
194 "Export the outline as a pretty ASCII file.
195 If there is an active region, export only the region.
196 The prefix ARG specifies how many levels of the outline should become
197 underlined headlines, default is 3. Lower levels will become bulleted
198 lists. EXT-PLIST is a property list with external parameters overriding
199 org-mode's default settings, but still inferior to file-local
200 settings. When TO-BUFFER is non-nil, create a buffer with that
201 name and export to that buffer. If TO-BUFFER is the symbol
202 `string', don't leave any buffer behind but just return the
203 resulting ASCII as a string. When BODY-ONLY is set, don't produce
204 the file header and footer. When PUB-DIR is set, use this as the
205 publishing directory."
207 (run-hooks 'org-export-first-hook
)
208 (setq-default org-todo-line-regexp org-todo-line-regexp
)
209 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
211 (org-infile-export-plist)))
212 (region-p (org-region-active-p))
213 (rbeg (and region-p
(region-beginning)))
214 (rend (and region-p
(region-end)))
216 (if (plist-get opt-plist
:ignore-subtree-p
)
221 (and (org-at-heading-p)
222 (>= (org-end-of-subtree t t
) rend
))))))
223 (level-offset (if subtree-p
226 (+ (funcall outline-level
)
227 (if org-odd-levels-only
1 0)))
229 (opt-plist (setq org-export-opt-plist
231 (org-export-add-subtree-options opt-plist rbeg
)
233 ;; The following two are dynamically scoped into other
235 (org-current-export-dir
236 (or pub-dir
(org-export-directory :html opt-plist
)))
237 (org-current-export-file buffer-file-name
)
238 (custom-times org-display-custom-times
)
239 (org-ascii-current-indentation '(0 .
0))
243 (case-fold-search nil
)
244 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
245 (filename (if to-buffer
247 (concat (file-name-as-directory
249 (org-export-directory :ascii opt-plist
)))
250 (file-name-sans-extension
252 (org-entry-get (region-beginning)
253 "EXPORT_FILE_NAME" t
))
254 (file-name-nondirectory bfname
)))
256 (filename (and filename
257 (if (equal (file-truename filename
)
258 (file-truename bfname
))
259 (concat filename
".txt")
261 (buffer (if to-buffer
263 ((eq to-buffer
'string
)
264 (get-buffer-create "*Org ASCII Export*"))
265 (t (get-buffer-create to-buffer
)))
266 (find-file-noselect filename
)))
267 (org-levels-open (make-vector org-level-max nil
))
268 (odd org-odd-levels-only
)
269 (date (plist-get opt-plist
:date
))
270 (author (plist-get opt-plist
:author
))
271 (title (or (and subtree-p
(org-export-get-title-from-subtree))
272 (plist-get opt-plist
:title
)
274 (plist-get opt-plist
:skip-before-1st-heading
))
275 (org-export-grab-title-from-buffer))
276 (and (buffer-file-name)
277 (file-name-sans-extension
278 (file-name-nondirectory bfname
)))
280 (email (plist-get opt-plist
:email
))
281 (language (plist-get opt-plist
:language
))
282 (quote-re0 (concat "^\\(" org-quote-string
"\\)\\( +\\|[ \t]*$\\)"))
287 (if (org-region-active-p) (region-beginning) (point-min))
288 (if (org-region-active-p) (region-end) (point-max))))
289 (org-export-footnotes-seen nil
)
290 (org-export-footnotes-data (org-footnote-all-labels 'with-defs
))
291 (lines (org-split-string
292 (org-export-preprocess-string
295 :skip-before-1st-heading
296 (plist-get opt-plist
:skip-before-1st-heading
)
297 :drawers
(plist-get opt-plist
:drawers
)
298 :tags
(plist-get opt-plist
:tags
)
299 :priority
(plist-get opt-plist
:priority
)
300 :footnotes
(plist-get opt-plist
:footnotes
)
301 :timestamps
(plist-get opt-plist
:timestamps
)
302 :todo-keywords
(plist-get opt-plist
:todo-keywords
)
303 :tasks
(plist-get opt-plist
:tasks
)
304 :verbatim-multiline t
305 :select-tags
(plist-get opt-plist
:select-tags
)
306 :exclude-tags
(plist-get opt-plist
:exclude-tags
)
308 (plist-get opt-plist
:archived-trees
)
309 :add-text
(plist-get opt-plist
:text
))
311 thetoc have-headings first-heading-pos
312 table-open table-buffer link-buffer link type path desc desc0 rpl wrap fnc
)
313 (let ((inhibit-read-only t
))
315 (remove-text-properties (point-min) (point-max)
316 '(:org-license-to-kill t
))))
318 (setq org-min-level
(org-get-min-level lines level-offset
))
319 (setq org-last-level org-min-level
)
320 (org-init-section-numbers)
321 (setq lang-words
(or (assoc language org-export-language-setup
)
322 (assoc "en" org-export-language-setup
)))
326 (org-install-letbind)
327 ;; create local variables for all options, to make sure all called
328 ;; functions get the correct information
330 (set (make-local-variable (nth 2 x
))
331 (plist-get opt-plist
(car x
))))
332 org-export-plist-vars
)
333 (org-set-local 'org-odd-levels-only odd
)
334 (setq umax
(if arg
(prefix-numeric-value arg
)
335 org-export-headline-levels
))
336 (setq umax-toc
(if (integerp org-export-with-toc
)
337 (min org-export-with-toc umax
)
342 (when (and title
(not (string= "" title
)))
343 (org-insert-centered title ?
=)
346 (if (and (or author email
)
347 org-export-author-info
)
348 (insert (concat (nth 1 lang-words
) ": " (or author
"")
349 (if (and org-export-email-info
350 email
(string-match "\\S-" email
))
351 (concat " <" email
">") "")
355 ((and date
(string-match "%" date
))
356 (setq date
(format-time-string date
)))
358 (t (setq date
(format-time-string "%Y-%m-%d %T %Z"))))
360 (if (and date org-export-time-stamp-file
)
361 (insert (concat (nth 2 lang-words
) ": " date
"\n")))
363 (unless (= (point) (point-min))
366 (if (and org-export-with-toc
(not body-only
))
368 (push (concat (nth 3 lang-words
) "\n") thetoc
)
369 (push (concat (make-string (string-width (nth 3 lang-words
)) ?
=)
371 (mapc #'(lambda (line)
372 (if (string-match org-todo-line-regexp
374 ;; This is a headline
376 (setq have-headings t
)
377 (setq level
(- (match-end 1) (match-beginning 1)
379 level
(org-tr-level level
)
380 txt
(match-string 3 line
)
382 (or (and org-export-mark-todo-in-toc
384 (not (member (match-string 2 line
)
387 (and org-export-mark-todo-in-toc
389 (org-search-todo-below
391 (setq txt
(org-html-expand-for-ascii txt
))
393 (while (string-match org-bracket-link-regexp txt
)
396 (match-string (if (match-end 2) 3 1) txt
)
399 (if (and (memq org-export-with-tags
'(not-in-toc nil
))
401 (org-re "[ \t]+:[[:alnum:]_@#%:]+:[ \t]*$")
403 (setq txt
(replace-match "" t t txt
)))
404 (if (string-match quote-re0 txt
)
405 (setq txt
(replace-match "" t t txt
1)))
407 (if org-export-with-section-numbers
408 (setq txt
(concat (org-section-number level
)
410 (if (<= level umax-toc
)
415 (* (max 0 (- level org-min-level
)) 4) ?\
)
416 (format (if todo
"%s (*)\n" "%s\n") txt
))
418 (setq org-last-level level
))
421 (setq thetoc
(if have-headings
(nreverse thetoc
) nil
))))
423 (org-init-section-numbers)
424 (while (setq line
(pop lines
))
425 (when (and link-buffer
(string-match org-outline-regexp-bol line
))
426 (org-export-ascii-push-links (nreverse link-buffer
))
427 (setq link-buffer nil
))
429 ;; Remove the quoted HTML tags.
430 (setq line
(org-html-expand-for-ascii line
))
431 ;; Replace links with the description when possible
432 (while (string-match org-bracket-link-analytic-regexp
++ line
)
433 (setq path
(match-string 3 line
)
434 link
(concat (match-string 1 line
) path
)
435 type
(match-string 2 line
)
436 desc0
(match-string 5 line
)
437 desc0
(replace-regexp-in-string "\\\\_" "_" desc0
)
439 desc
(replace-regexp-in-string "\\\\_" "_" desc
))
440 (if (and (> (length link
) 8)
441 (equal (substring link
0 8) "coderef:"))
442 (setq line
(replace-match
443 (format (org-export-get-coderef-format (substring link
8) desc
)
446 org-export-code-refs
)))
448 (setq rpl
(concat "[" desc
"]"))
449 (if (functionp (setq fnc
(nth 2 (assoc type org-link-protocols
))))
450 (setq rpl
(or (save-match-data
451 (funcall fnc
(org-link-unescape path
)
454 (when (and desc0
(not (equal desc0 link
)))
455 (if org-export-ascii-links-to-notes
456 (push (cons desc0 link
) link-buffer
)
457 (setq rpl
(concat rpl
" (" link
")")
458 wrap
(+ (length line
) (- (length (match-string 0 line
)))
460 (setq line
(replace-match rpl t t line
))))
462 (setq line
(org-translate-time line
)))
464 ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line
)
466 (setq first-heading-pos
(or first-heading-pos
(point)))
467 (setq level
(org-tr-level (- (match-end 1) (match-beginning 1)
469 txt
(match-string 2 line
))
470 (org-ascii-level-start level txt umax lines
))
472 ((and org-export-with-tables
473 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line
))
476 (setq table-open t table-buffer nil
))
478 (setq table-buffer
(cons line table-buffer
))
479 (when (or (not lines
)
480 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
483 table-buffer
(nreverse table-buffer
))
486 (org-fix-indentation x org-ascii-current-indentation
))
487 (org-format-table-ascii table-buffer
)
490 (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)"
492 (setq line
(replace-match "\\1\\3:" t nil line
)))
493 (setq line
(org-fix-indentation line org-ascii-current-indentation
))
494 ;; Remove forced line breaks
495 (if (string-match "\\\\\\\\[ \t]*$" line
)
496 (setq line
(replace-match "" t t line
)))
497 (if (and org-export-with-fixed-width
498 (string-match "^\\([ \t]*\\)\\(:\\( \\|$\\)\\)" line
))
499 (setq line
(replace-match "\\1" nil nil line
))
500 (if wrap
(setq line
(org-export-ascii-wrap line wrap
))))
501 (insert line
"\n"))))
503 (org-export-ascii-push-links (nreverse link-buffer
))
507 ;; insert the table of contents
509 (goto-char (point-min))
510 (if (re-search-forward "^[ \t]*\\[TABLE-OF-CONTENTS\\][ \t]*$" nil t
)
512 (goto-char (match-beginning 0))
514 (goto-char first-heading-pos
))
515 (mapc 'insert thetoc
)
516 (or (looking-at "[ \t]*\n[ \t]*\n")
519 ;; Convert whitespace place holders
520 (goto-char (point-min))
522 (while (setq beg
(next-single-property-change (point) 'org-whitespace
))
523 (setq end
(next-single-property-change beg
'org-whitespace
))
525 (delete-region beg end
)
526 (insert (make-string (- end beg
) ?\
))))
528 ;; remove display and invisible chars
530 (goto-char (point-min))
531 (while (setq beg
(next-single-property-change (point) 'display
))
532 (setq end
(next-single-property-change beg
'display
))
533 (delete-region beg end
)
536 (goto-char (point-min))
537 (while (setq beg
(next-single-property-change (point) 'org-cwidth
))
538 (setq end
(next-single-property-change beg
'org-cwidth
))
539 (delete-region beg end
)
541 (run-hooks 'org-export-ascii-final-hook
)
542 (or to-buffer
(save-buffer))
543 (goto-char (point-min))
544 (or (org-export-push-to-kill-ring "ASCII")
545 (message "Exporting... done"))
546 ;; Return the buffer or a string, according to how this function was called
547 (if (eq to-buffer
'string
)
548 (prog1 (buffer-substring (point-min) (point-max))
549 (kill-buffer (current-buffer)))
553 (defun org-export-ascii-preprocess (parameters)
554 "Do extra work for ASCII export."
556 ;; Realign tables to get rid of narrowing
557 (when org-export-ascii-table-widen-columns
558 (let ((org-table-do-narrow nil
))
559 (goto-char (point-min))
560 (org-ascii-replace-entities)
561 (goto-char (point-min))
562 (org-table-map-tables
563 (lambda () (org-if-unprotected (org-table-align)))
565 ;; Put quotes around verbatim text
566 (goto-char (point-min))
567 (while (re-search-forward org-verbatim-re nil t
)
568 (org-if-unprotected-at (match-beginning 4)
569 (goto-char (match-end 2))
570 (backward-delete-char 1) (insert "'")
571 (goto-char (match-beginning 2))
572 (delete-char 1) (insert "`")
573 (goto-char (match-end 2))))
574 ;; Remove target markers
575 (goto-char (point-min))
576 (while (re-search-forward "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t
)
577 (org-if-unprotected-at (match-beginning 1)
578 (replace-match "\\1\\2")))
579 ;; Remove list start counters
580 (goto-char (point-min))
581 (while (org-list-search-forward
582 "\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*" nil t
)
584 (remove-text-properties
585 (point-min) (point-max)
586 '(face nil font-lock-fontified nil font-lock-multiline nil line-prefix nil wrap-prefix nil
)))
588 (defun org-html-expand-for-ascii (line)
589 "Handle quoted HTML for ASCII export."
590 (if org-export-html-expand
591 (while (string-match "@<[^<>\n]*>" line
)
592 ;; We just remove the tags for now.
593 (setq line
(replace-match "" nil nil line
))))
596 (defun org-ascii-replace-entities ()
597 "Replace entities with the ASCII representation."
599 (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?" nil t
)
600 (org-if-unprotected-at (match-beginning 1)
601 (setq e
(org-entity-get-representation (match-string 1)
602 org-export-ascii-entities
))
603 (and e
(replace-match e t t
))))))
605 (defun org-export-ascii-wrap (line where
)
606 "Wrap LINE at or before WHERE."
607 (let ((ind (org-get-indentation line
))
610 (loop for i from where downto
(/ where
2) do
611 (and (equal (aref line i
) ?\
)
615 (concat (substring line
0 pos
) "\n"
616 (make-string ind ?\
)
617 (substring line
(1+ pos
)))
620 (defun org-export-ascii-push-links (link-buffer)
621 "Push out links in the buffer."
623 ;; We still have links to push out.
629 (concat "^\\(\\([ \t]*\\)\\|\\("
631 "\\)\\)[^ \t\n]") nil t
))
632 (setq ind
(or (match-string 2)
633 (make-string (length (match-string 3)) ?\
)))))
634 (mapc (lambda (x) (insert ind
"[" (car x
) "]: " (cdr x
) "\n"))
638 (defun org-ascii-level-start (level title umax
&optional lines
)
639 "Insert a new level in ASCII export."
640 (let (char (n (- level umax
1)) (ind 0))
643 (insert (make-string (* 2 n
) ?\
)
644 (char-to-string (nth (% n
(length org-export-ascii-bullets
))
645 org-export-ascii-bullets
))
647 ;; find the indentation of the next non-empty line
650 (if (string-match "^\\* " (car lines
)) (throw 'stop nil
))
651 (if (string-match "^\\([ \t]*\\)\\S-" (car lines
))
652 (throw 'stop
(setq ind
(org-get-indentation (car lines
)))))
654 (setq org-ascii-current-indentation
(cons (* 2 (1+ n
)) ind
)))
655 (if (or (not (equal (char-before) ?
\n))
656 (not (equal (char-before (1- (point))) ?
\n)))
658 (setq char
(or (nth (1- level
) org-export-ascii-underline
)
659 (car (last org-export-ascii-underline
))))
660 (unless org-export-with-tags
661 (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title
)
662 (setq title
(replace-match "" t t title
))))
663 (if org-export-with-section-numbers
664 (setq title
(concat (org-section-number level
) " " title
)))
665 (insert title
"\n" (make-string (string-width title
) char
) "\n")
666 (setq org-ascii-current-indentation
'(0 .
0)))))
668 (defun org-insert-centered (s &optional underline
)
669 "Insert the string S centered and underline it with character UNDERLINE."
670 (let ((ind (max (/ (- fill-column
(string-width s
)) 2) 0)))
671 (insert (make-string ind ?\
) s
"\n")
673 (insert (make-string ind ?\
)
674 (make-string (string-width s
) underline
)
677 (defvar org-table-colgroup-info nil
)
678 (defun org-format-table-ascii (lines)
679 "Format a table for ascii export."
681 (setq lines
(org-split-string lines
"\n")))
682 (if (not (string-match "^[ \t]*|" (car lines
)))
683 ;; Table made by table.el - test for spanning
686 ;; A normal org table
687 ;; Get rid of hlines at beginning and end
688 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
689 (setq lines
(nreverse lines
))
690 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
691 (setq lines
(nreverse lines
))
692 (when org-export-table-remove-special-lines
693 ;; Check if the table has a marking column. If yes remove the
694 ;; column and the special lines
695 (setq lines
(org-table-clean-before-export lines
)))
696 ;; Get rid of the vertical lines except for grouping
697 (if org-export-ascii-table-keep-all-vertical-lines
699 (let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info
))
701 (while (setq line
(pop lines
))
702 (if (string-match org-table-hline-regexp line
)
703 (and (string-match "|\\(.*\\)|" line
)
704 (setq line
(replace-match " \\1" t nil line
)))
705 (setq start
0 vl1 vl
)
706 (while (string-match "|" line start
)
707 (setq start
(match-end 0))
708 (or (pop vl1
) (setq line
(replace-match " " t t line
)))))
712 (defun org-colgroup-info-to-vline-list (info)
715 (setq last new new
(pop info
))
716 (if (or (memq last
'(:end
:startend
))
717 (memq new
'(:start
:startend
)))
720 (setq vl
(nreverse vl
))
721 (and vl
(setcar vl nil
))
727 ;; generated-autoload-file: "org-loaddefs.el"
730 ;;; org-ascii.el ends here