1 ;;; org-ascii.el --- ASCII export for Org-mode
3 ;; Copyright (C) 2004-2011 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 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 (eq major-mode
'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
189 (if (fboundp 'deactivate-mark
) (deactivate-mark))
190 (if (and (org-called-interactively-p 'any
) (bufferp rtn
))
191 (switch-to-buffer-other-window rtn
)
195 (defun org-export-as-ascii (arg &optional hidden ext-plist
196 to-buffer body-only pub-dir
)
197 "Export the outline as a pretty ASCII file.
198 If there is an active region, export only the region.
199 The prefix ARG specifies how many levels of the outline should become
200 underlined headlines, default is 3. Lower levels will become bulleted
201 lists. When HIDDEN is non-nil, don't display the ASCII buffer.
202 EXT-PLIST is a property list with external parameters overriding
203 org-mode's default settings, but still inferior to file-local
204 settings. When TO-BUFFER is non-nil, create a buffer with that
205 name and export to that buffer. If TO-BUFFER is the symbol
206 `string', don't leave any buffer behind but just return the
207 resulting ASCII as a string. When BODY-ONLY is set, don't produce
208 the file header and footer. When PUB-DIR is set, use this as the
209 publishing directory."
211 (run-hooks 'org-export-first-hook
)
212 (setq-default org-todo-line-regexp org-todo-line-regexp
)
213 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
215 (org-infile-export-plist)))
216 (region-p (org-region-active-p))
217 (rbeg (and region-p
(region-beginning)))
218 (rend (and region-p
(region-end)))
220 (if (plist-get opt-plist
:ignore-subtree-p
)
225 (and (org-at-heading-p)
226 (>= (org-end-of-subtree t t
) rend
))))))
227 (level-offset (if subtree-p
230 (+ (funcall outline-level
)
231 (if org-odd-levels-only
1 0)))
233 (opt-plist (setq org-export-opt-plist
235 (org-export-add-subtree-options opt-plist rbeg
)
237 ;; The following two are dynamically scoped into other
239 (org-current-export-dir
240 (or pub-dir
(org-export-directory :html opt-plist
)))
241 (org-current-export-file buffer-file-name
)
242 (custom-times org-display-custom-times
)
243 (org-ascii-current-indentation '(0 .
0))
247 (case-fold-search nil
)
248 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
249 (filename (if to-buffer
251 (concat (file-name-as-directory
253 (org-export-directory :ascii opt-plist
)))
254 (file-name-sans-extension
256 (org-entry-get (region-beginning)
257 "EXPORT_FILE_NAME" t
))
258 (file-name-nondirectory bfname
)))
260 (filename (and filename
261 (if (equal (file-truename filename
)
262 (file-truename bfname
))
263 (concat filename
".txt")
265 (buffer (if to-buffer
267 ((eq to-buffer
'string
)
268 (get-buffer-create "*Org ASCII Export*"))
269 (t (get-buffer-create to-buffer
)))
270 (find-file-noselect filename
)))
271 (org-levels-open (make-vector org-level-max nil
))
272 (odd org-odd-levels-only
)
273 (date (plist-get opt-plist
:date
))
274 (author (plist-get opt-plist
:author
))
275 (title (or (and subtree-p
(org-export-get-title-from-subtree))
276 (plist-get opt-plist
:title
)
278 (plist-get opt-plist
:skip-before-1st-heading
))
279 (org-export-grab-title-from-buffer))
280 (and (buffer-file-name)
281 (file-name-sans-extension
282 (file-name-nondirectory bfname
)))
284 (email (plist-get opt-plist
:email
))
285 (language (plist-get opt-plist
:language
))
286 (quote-re0 (concat "^\\(" org-quote-string
"\\)\\( +\\|[ \t]*$\\)"))
291 (if (org-region-active-p) (region-beginning) (point-min))
292 (if (org-region-active-p) (region-end) (point-max))))
293 (org-export-footnotes-seen nil
)
294 (org-export-footnotes-data (org-footnote-all-labels 'with-defs
))
295 (lines (org-split-string
296 (org-export-preprocess-string
299 :skip-before-1st-heading
300 (plist-get opt-plist
:skip-before-1st-heading
)
301 :drawers
(plist-get opt-plist
:drawers
)
302 :tags
(plist-get opt-plist
:tags
)
303 :priority
(plist-get opt-plist
:priority
)
304 :footnotes
(plist-get opt-plist
:footnotes
)
305 :timestamps
(plist-get opt-plist
:timestamps
)
306 :todo-keywords
(plist-get opt-plist
:todo-keywords
)
307 :tasks
(plist-get opt-plist
:tasks
)
308 :verbatim-multiline t
309 :select-tags
(plist-get opt-plist
:select-tags
)
310 :exclude-tags
(plist-get opt-plist
:exclude-tags
)
312 (plist-get opt-plist
:archived-trees
)
313 :add-text
(plist-get opt-plist
:text
))
315 thetoc have-headings first-heading-pos
316 table-open table-buffer link-buffer link type path desc desc0 rpl wrap fnc
)
317 (let ((inhibit-read-only t
))
319 (remove-text-properties (point-min) (point-max)
320 '(:org-license-to-kill t
))))
322 (setq org-min-level
(org-get-min-level lines level-offset
))
323 (setq org-last-level org-min-level
)
324 (org-init-section-numbers)
325 (setq lang-words
(or (assoc language org-export-language-setup
)
326 (assoc "en" org-export-language-setup
)))
330 (org-install-letbind)
331 ;; create local variables for all options, to make sure all called
332 ;; functions get the correct information
334 (set (make-local-variable (nth 2 x
))
335 (plist-get opt-plist
(car x
))))
336 org-export-plist-vars
)
337 (org-set-local 'org-odd-levels-only odd
)
338 (setq umax
(if arg
(prefix-numeric-value arg
)
339 org-export-headline-levels
))
340 (setq umax-toc
(if (integerp org-export-with-toc
)
341 (min org-export-with-toc umax
)
346 (when (and title
(not (string= "" title
)))
347 (org-insert-centered title ?
=)
350 (if (and (or author email
)
351 org-export-author-info
)
352 (insert (concat (nth 1 lang-words
) ": " (or author
"")
353 (if (and org-export-email-info
354 email
(string-match "\\S-" email
))
355 (concat " <" email
">") "")
359 ((and date
(string-match "%" date
))
360 (setq date
(format-time-string date
)))
362 (t (setq date
(format-time-string "%Y-%m-%d %T %Z"))))
364 (if (and date org-export-time-stamp-file
)
365 (insert (concat (nth 2 lang-words
) ": " date
"\n")))
367 (unless (= (point) (point-min))
370 (if (and org-export-with-toc
(not body-only
))
372 (push (concat (nth 3 lang-words
) "\n") thetoc
)
373 (push (concat (make-string (string-width (nth 3 lang-words
)) ?
=)
375 (mapc #'(lambda (line)
376 (if (string-match org-todo-line-regexp
378 ;; This is a headline
380 (setq have-headings t
)
381 (setq level
(- (match-end 1) (match-beginning 1)
383 level
(org-tr-level level
)
384 txt
(match-string 3 line
)
386 (or (and org-export-mark-todo-in-toc
388 (not (member (match-string 2 line
)
391 (and org-export-mark-todo-in-toc
393 (org-search-todo-below
395 (setq txt
(org-html-expand-for-ascii txt
))
397 (while (string-match org-bracket-link-regexp txt
)
400 (match-string (if (match-end 2) 3 1) txt
)
403 (if (and (memq org-export-with-tags
'(not-in-toc nil
))
405 (org-re "[ \t]+:[[:alnum:]_@#%:]+:[ \t]*$")
407 (setq txt
(replace-match "" t t txt
)))
408 (if (string-match quote-re0 txt
)
409 (setq txt
(replace-match "" t t txt
1)))
411 (if org-export-with-section-numbers
412 (setq txt
(concat (org-section-number level
)
414 (if (<= level umax-toc
)
419 (* (max 0 (- level org-min-level
)) 4) ?\
)
420 (format (if todo
"%s (*)\n" "%s\n") txt
))
422 (setq org-last-level level
))
425 (setq thetoc
(if have-headings
(nreverse thetoc
) nil
))))
427 (org-init-section-numbers)
428 (while (setq line
(pop lines
))
429 (when (and link-buffer
(string-match org-outline-regexp-bol line
))
430 (org-export-ascii-push-links (nreverse link-buffer
))
431 (setq link-buffer nil
))
433 ;; Remove the quoted HTML tags.
434 (setq line
(org-html-expand-for-ascii line
))
435 ;; Replace links with the description when possible
436 (while (string-match org-bracket-link-analytic-regexp
++ line
)
437 (setq path
(match-string 3 line
)
438 link
(concat (match-string 1 line
) path
)
439 type
(match-string 2 line
)
440 desc0
(match-string 5 line
)
441 desc
(or desc0 link
))
442 (if (and (> (length link
) 8)
443 (equal (substring link
0 8) "coderef:"))
444 (setq line
(replace-match
445 (format (org-export-get-coderef-format (substring link
8) desc
)
448 org-export-code-refs
)))
450 (setq rpl
(concat "[" desc
"]"))
451 (if (functionp (setq fnc
(nth 2 (assoc type org-link-protocols
))))
452 (setq rpl
(or (save-match-data
453 (funcall fnc
(org-link-unescape path
)
456 (when (and desc0
(not (equal desc0 link
)))
457 (if org-export-ascii-links-to-notes
458 (push (cons desc0 link
) link-buffer
)
459 (setq rpl
(concat rpl
" (" link
")")
460 wrap
(+ (length line
) (- (length (match-string 0 line
)))
462 (setq line
(replace-match rpl t t line
))))
464 (setq line
(org-translate-time line
)))
466 ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line
)
468 (setq first-heading-pos
(or first-heading-pos
(point)))
469 (setq level
(org-tr-level (- (match-end 1) (match-beginning 1)
471 txt
(match-string 2 line
))
472 (org-ascii-level-start level txt umax lines
))
474 ((and org-export-with-tables
475 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line
))
478 (setq table-open t table-buffer nil
))
480 (setq table-buffer
(cons line table-buffer
))
481 (when (or (not lines
)
482 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
485 table-buffer
(nreverse table-buffer
))
488 (org-fix-indentation x org-ascii-current-indentation
))
489 (org-format-table-ascii table-buffer
)
492 (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)"
494 (setq line
(replace-match "\\1\\3:" t nil line
)))
495 (setq line
(org-fix-indentation line org-ascii-current-indentation
))
496 ;; Remove forced line breaks
497 (if (string-match "\\\\\\\\[ \t]*$" line
)
498 (setq line
(replace-match "" t t line
)))
499 (if (and org-export-with-fixed-width
500 (string-match "^\\([ \t]*\\)\\(:\\( \\|$\\)\\)" line
))
501 (setq line
(replace-match "\\1" nil nil line
))
502 (if wrap
(setq line
(org-export-ascii-wrap line wrap
))))
503 (insert line
"\n"))))
505 (org-export-ascii-push-links (nreverse link-buffer
))
509 ;; insert the table of contents
511 (goto-char (point-min))
512 (if (re-search-forward "^[ \t]*\\[TABLE-OF-CONTENTS\\][ \t]*$" nil t
)
514 (goto-char (match-beginning 0))
516 (goto-char first-heading-pos
))
517 (mapc 'insert thetoc
)
518 (or (looking-at "[ \t]*\n[ \t]*\n")
521 ;; Convert whitespace place holders
522 (goto-char (point-min))
524 (while (setq beg
(next-single-property-change (point) 'org-whitespace
))
525 (setq end
(next-single-property-change beg
'org-whitespace
))
527 (delete-region beg end
)
528 (insert (make-string (- end beg
) ?\
))))
530 ;; remove display and invisible chars
532 (goto-char (point-min))
533 (while (setq beg
(next-single-property-change (point) 'display
))
534 (setq end
(next-single-property-change beg
'display
))
535 (delete-region beg end
)
538 (goto-char (point-min))
539 (while (setq beg
(next-single-property-change (point) 'org-cwidth
))
540 (setq end
(next-single-property-change beg
'org-cwidth
))
541 (delete-region beg end
)
543 (run-hooks 'org-export-ascii-final-hook
)
544 (or to-buffer
(save-buffer))
545 (goto-char (point-min))
546 (or (org-export-push-to-kill-ring "ASCII")
547 (message "Exporting... done"))
548 ;; Return the buffer or a string, according to how this function was called
549 (if (eq to-buffer
'string
)
550 (prog1 (buffer-substring (point-min) (point-max))
551 (kill-buffer (current-buffer)))
554 (defun org-export-ascii-preprocess (parameters)
555 "Do extra work for ASCII export."
557 ;; Realign tables to get rid of narrowing
558 (when org-export-ascii-table-widen-columns
559 (let ((org-table-do-narrow nil
))
560 (goto-char (point-min))
561 (org-ascii-replace-entities)
562 (goto-char (point-min))
563 (org-table-map-tables
564 (lambda () (org-if-unprotected (org-table-align)))
566 ;; Put quotes around verbatim text
567 (goto-char (point-min))
568 (while (re-search-forward org-verbatim-re nil t
)
569 (org-if-unprotected-at (match-beginning 4)
570 (goto-char (match-end 2))
571 (backward-delete-char 1) (insert "'")
572 (goto-char (match-beginning 2))
573 (delete-char 1) (insert "`")
574 (goto-char (match-end 2))))
575 ;; Remove target markers
576 (goto-char (point-min))
577 (while (re-search-forward "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t
)
578 (org-if-unprotected-at (match-beginning 1)
579 (replace-match "\\1\\2")))
580 ;; Remove list start counters
581 (goto-char (point-min))
582 (while (org-list-search-forward
583 "\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*" nil t
)
585 (remove-text-properties
586 (point-min) (point-max)
587 '(face nil font-lock-fontified nil font-lock-multiline nil line-prefix nil wrap-prefix nil
)))
589 (defun org-html-expand-for-ascii (line)
590 "Handle quoted HTML for ASCII export."
591 (if org-export-html-expand
592 (while (string-match "@<[^<>\n]*>" line
)
593 ;; We just remove the tags for now.
594 (setq line
(replace-match "" nil nil line
))))
597 (defun org-ascii-replace-entities ()
598 "Replace entities with the ASCII representation."
600 (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?" nil t
)
601 (org-if-unprotected-at (match-beginning 1)
602 (setq e
(org-entity-get-representation (match-string 1)
603 org-export-ascii-entities
))
604 (and e
(replace-match e t t
))))))
606 (defun org-export-ascii-wrap (line where
)
607 "Wrap LINE at or before WHERE."
608 (let ((ind (org-get-indentation line
))
611 (loop for i from where downto
(/ where
2) do
612 (and (equal (aref line i
) ?\
)
616 (concat (substring line
0 pos
) "\n"
617 (make-string ind ?\
)
618 (substring line
(1+ pos
)))
621 (defun org-export-ascii-push-links (link-buffer)
622 "Push out links in the buffer."
624 ;; We still have links to push out.
630 (concat "^\\(\\([ \t]*\\)\\|\\("
632 "\\)\\)[^ \t\n]") nil t
))
633 (setq ind
(or (match-string 2)
634 (make-string (length (match-string 3)) ?\
)))))
635 (mapc (lambda (x) (insert ind
"[" (car x
) "]: " (cdr x
) "\n"))
639 (defun org-ascii-level-start (level title umax
&optional lines
)
640 "Insert a new level in ASCII export."
641 (let (char (n (- level umax
1)) (ind 0))
644 (insert (make-string (* 2 n
) ?\
)
645 (char-to-string (nth (% n
(length org-export-ascii-bullets
))
646 org-export-ascii-bullets
))
648 ;; find the indentation of the next non-empty line
651 (if (string-match "^\\* " (car lines
)) (throw 'stop nil
))
652 (if (string-match "^\\([ \t]*\\)\\S-" (car lines
))
653 (throw 'stop
(setq ind
(org-get-indentation (car lines
)))))
655 (setq org-ascii-current-indentation
(cons (* 2 (1+ n
)) ind
)))
656 (if (or (not (equal (char-before) ?
\n))
657 (not (equal (char-before (1- (point))) ?
\n)))
659 (setq char
(or (nth (1- level
) org-export-ascii-underline
)
660 (car (last org-export-ascii-underline
))))
661 (unless org-export-with-tags
662 (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title
)
663 (setq title
(replace-match "" t t title
))))
664 (if org-export-with-section-numbers
665 (setq title
(concat (org-section-number level
) " " title
)))
666 (insert title
"\n" (make-string (string-width title
) char
) "\n")
667 (setq org-ascii-current-indentation
'(0 .
0)))))
669 (defun org-insert-centered (s &optional underline
)
670 "Insert the string S centered and underline it with character UNDERLINE."
671 (let ((ind (max (/ (- fill-column
(string-width s
)) 2) 0)))
672 (insert (make-string ind ?\
) s
"\n")
674 (insert (make-string ind ?\
)
675 (make-string (string-width s
) underline
)
678 (defvar org-table-colgroup-info nil
)
679 (defun org-format-table-ascii (lines)
680 "Format a table for ascii export."
682 (setq lines
(org-split-string lines
"\n")))
683 (if (not (string-match "^[ \t]*|" (car lines
)))
684 ;; Table made by table.el - test for spanning
687 ;; A normal org table
688 ;; Get rid of hlines at beginning and end
689 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
690 (setq lines
(nreverse lines
))
691 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
692 (setq lines
(nreverse lines
))
693 (when org-export-table-remove-special-lines
694 ;; Check if the table has a marking column. If yes remove the
695 ;; column and the special lines
696 (setq lines
(org-table-clean-before-export lines
)))
697 ;; Get rid of the vertical lines except for grouping
698 (if org-export-ascii-table-keep-all-vertical-lines
700 (let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info
))
702 (while (setq line
(pop lines
))
703 (if (string-match org-table-hline-regexp line
)
704 (and (string-match "|\\(.*\\)|" line
)
705 (setq line
(replace-match " \\1" t nil line
)))
706 (setq start
0 vl1 vl
)
707 (while (string-match "|" line start
)
708 (setq start
(match-end 0))
709 (or (pop vl1
) (setq line
(replace-match " " t t line
)))))
713 (defun org-colgroup-info-to-vline-list (info)
716 (setq last new new
(pop info
))
717 (if (or (memq last
'(:end
:startend
))
718 (memq new
'(:start
:startend
)))
721 (setq vl
(nreverse vl
))
722 (and vl
(setcar vl nil
))
727 ;;; org-ascii.el ends here