1 ;;; org-ascii.el --- ASCII export for Org-mode
3 ;; Copyright (C) 2004-2012 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 (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
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 desc0
(replace-regexp-in-string "\\\\_" "_" desc0
)
443 desc
(replace-regexp-in-string "\\\\_" "_" desc
))
444 (if (and (> (length link
) 8)
445 (equal (substring link
0 8) "coderef:"))
446 (setq line
(replace-match
447 (format (org-export-get-coderef-format (substring link
8) desc
)
450 org-export-code-refs
)))
452 (setq rpl
(concat "[" desc
"]"))
453 (if (functionp (setq fnc
(nth 2 (assoc type org-link-protocols
))))
454 (setq rpl
(or (save-match-data
455 (funcall fnc
(org-link-unescape path
)
458 (when (and desc0
(not (equal desc0 link
)))
459 (if org-export-ascii-links-to-notes
460 (push (cons desc0 link
) link-buffer
)
461 (setq rpl
(concat rpl
" (" link
")")
462 wrap
(+ (length line
) (- (length (match-string 0 line
)))
464 (setq line
(replace-match rpl t t line
))))
466 (setq line
(org-translate-time line
)))
468 ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line
)
470 (setq first-heading-pos
(or first-heading-pos
(point)))
471 (setq level
(org-tr-level (- (match-end 1) (match-beginning 1)
473 txt
(match-string 2 line
))
474 (org-ascii-level-start level txt umax lines
))
476 ((and org-export-with-tables
477 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line
))
480 (setq table-open t table-buffer nil
))
482 (setq table-buffer
(cons line table-buffer
))
483 (when (or (not lines
)
484 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
487 table-buffer
(nreverse table-buffer
))
490 (org-fix-indentation x org-ascii-current-indentation
))
491 (org-format-table-ascii table-buffer
)
494 (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)"
496 (setq line
(replace-match "\\1\\3:" t nil line
)))
497 (setq line
(org-fix-indentation line org-ascii-current-indentation
))
498 ;; Remove forced line breaks
499 (if (string-match "\\\\\\\\[ \t]*$" line
)
500 (setq line
(replace-match "" t t line
)))
501 (if (and org-export-with-fixed-width
502 (string-match "^\\([ \t]*\\)\\(:\\( \\|$\\)\\)" line
))
503 (setq line
(replace-match "\\1" nil nil line
))
504 (if wrap
(setq line
(org-export-ascii-wrap line wrap
))))
505 (insert line
"\n"))))
507 (org-export-ascii-push-links (nreverse link-buffer
))
511 ;; insert the table of contents
513 (goto-char (point-min))
514 (if (re-search-forward "^[ \t]*\\[TABLE-OF-CONTENTS\\][ \t]*$" nil t
)
516 (goto-char (match-beginning 0))
518 (goto-char first-heading-pos
))
519 (mapc 'insert thetoc
)
520 (or (looking-at "[ \t]*\n[ \t]*\n")
523 ;; Convert whitespace place holders
524 (goto-char (point-min))
526 (while (setq beg
(next-single-property-change (point) 'org-whitespace
))
527 (setq end
(next-single-property-change beg
'org-whitespace
))
529 (delete-region beg end
)
530 (insert (make-string (- end beg
) ?\
))))
532 ;; remove display and invisible chars
534 (goto-char (point-min))
535 (while (setq beg
(next-single-property-change (point) 'display
))
536 (setq end
(next-single-property-change beg
'display
))
537 (delete-region beg end
)
540 (goto-char (point-min))
541 (while (setq beg
(next-single-property-change (point) 'org-cwidth
))
542 (setq end
(next-single-property-change beg
'org-cwidth
))
543 (delete-region beg end
)
545 (run-hooks 'org-export-ascii-final-hook
)
546 (or to-buffer
(save-buffer))
547 (goto-char (point-min))
548 (or (org-export-push-to-kill-ring "ASCII")
549 (message "Exporting... done"))
550 ;; Return the buffer or a string, according to how this function was called
551 (if (eq to-buffer
'string
)
552 (prog1 (buffer-substring (point-min) (point-max))
553 (kill-buffer (current-buffer)))
557 (defun org-export-ascii-preprocess (parameters)
558 "Do extra work for ASCII export."
560 ;; Realign tables to get rid of narrowing
561 (when org-export-ascii-table-widen-columns
562 (let ((org-table-do-narrow nil
))
563 (goto-char (point-min))
564 (org-ascii-replace-entities)
565 (goto-char (point-min))
566 (org-table-map-tables
567 (lambda () (org-if-unprotected (org-table-align)))
569 ;; Put quotes around verbatim text
570 (goto-char (point-min))
571 (while (re-search-forward org-verbatim-re nil t
)
572 (org-if-unprotected-at (match-beginning 4)
573 (goto-char (match-end 2))
574 (backward-delete-char 1) (insert "'")
575 (goto-char (match-beginning 2))
576 (delete-char 1) (insert "`")
577 (goto-char (match-end 2))))
578 ;; Remove target markers
579 (goto-char (point-min))
580 (while (re-search-forward "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t
)
581 (org-if-unprotected-at (match-beginning 1)
582 (replace-match "\\1\\2")))
583 ;; Remove list start counters
584 (goto-char (point-min))
585 (while (org-list-search-forward
586 "\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*" nil t
)
588 (remove-text-properties
589 (point-min) (point-max)
590 '(face nil font-lock-fontified nil font-lock-multiline nil line-prefix nil wrap-prefix nil
)))
592 (defun org-html-expand-for-ascii (line)
593 "Handle quoted HTML for ASCII export."
594 (if org-export-html-expand
595 (while (string-match "@<[^<>\n]*>" line
)
596 ;; We just remove the tags for now.
597 (setq line
(replace-match "" nil nil line
))))
600 (defun org-ascii-replace-entities ()
601 "Replace entities with the ASCII representation."
603 (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?" nil t
)
604 (org-if-unprotected-at (match-beginning 1)
605 (setq e
(org-entity-get-representation (match-string 1)
606 org-export-ascii-entities
))
607 (and e
(replace-match e t t
))))))
609 (defun org-export-ascii-wrap (line where
)
610 "Wrap LINE at or before WHERE."
611 (let ((ind (org-get-indentation line
))
614 (loop for i from where downto
(/ where
2) do
615 (and (equal (aref line i
) ?\
)
619 (concat (substring line
0 pos
) "\n"
620 (make-string ind ?\
)
621 (substring line
(1+ pos
)))
624 (defun org-export-ascii-push-links (link-buffer)
625 "Push out links in the buffer."
627 ;; We still have links to push out.
633 (concat "^\\(\\([ \t]*\\)\\|\\("
635 "\\)\\)[^ \t\n]") nil t
))
636 (setq ind
(or (match-string 2)
637 (make-string (length (match-string 3)) ?\
)))))
638 (mapc (lambda (x) (insert ind
"[" (car x
) "]: " (cdr x
) "\n"))
642 (defun org-ascii-level-start (level title umax
&optional lines
)
643 "Insert a new level in ASCII export."
644 (let (char (n (- level umax
1)) (ind 0))
647 (insert (make-string (* 2 n
) ?\
)
648 (char-to-string (nth (% n
(length org-export-ascii-bullets
))
649 org-export-ascii-bullets
))
651 ;; find the indentation of the next non-empty line
654 (if (string-match "^\\* " (car lines
)) (throw 'stop nil
))
655 (if (string-match "^\\([ \t]*\\)\\S-" (car lines
))
656 (throw 'stop
(setq ind
(org-get-indentation (car lines
)))))
658 (setq org-ascii-current-indentation
(cons (* 2 (1+ n
)) ind
)))
659 (if (or (not (equal (char-before) ?
\n))
660 (not (equal (char-before (1- (point))) ?
\n)))
662 (setq char
(or (nth (1- level
) org-export-ascii-underline
)
663 (car (last org-export-ascii-underline
))))
664 (unless org-export-with-tags
665 (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title
)
666 (setq title
(replace-match "" t t title
))))
667 (if org-export-with-section-numbers
668 (setq title
(concat (org-section-number level
) " " title
)))
669 (insert title
"\n" (make-string (string-width title
) char
) "\n")
670 (setq org-ascii-current-indentation
'(0 .
0)))))
672 (defun org-insert-centered (s &optional underline
)
673 "Insert the string S centered and underline it with character UNDERLINE."
674 (let ((ind (max (/ (- fill-column
(string-width s
)) 2) 0)))
675 (insert (make-string ind ?\
) s
"\n")
677 (insert (make-string ind ?\
)
678 (make-string (string-width s
) underline
)
681 (defvar org-table-colgroup-info nil
)
682 (defun org-format-table-ascii (lines)
683 "Format a table for ascii export."
685 (setq lines
(org-split-string lines
"\n")))
686 (if (not (string-match "^[ \t]*|" (car lines
)))
687 ;; Table made by table.el - test for spanning
690 ;; A normal org table
691 ;; Get rid of hlines at beginning and end
692 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
693 (setq lines
(nreverse lines
))
694 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
695 (setq lines
(nreverse lines
))
696 (when org-export-table-remove-special-lines
697 ;; Check if the table has a marking column. If yes remove the
698 ;; column and the special lines
699 (setq lines
(org-table-clean-before-export lines
)))
700 ;; Get rid of the vertical lines except for grouping
701 (if org-export-ascii-table-keep-all-vertical-lines
703 (let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info
))
705 (while (setq line
(pop lines
))
706 (if (string-match org-table-hline-regexp line
)
707 (and (string-match "|\\(.*\\)|" line
)
708 (setq line
(replace-match " \\1" t nil line
)))
709 (setq start
0 vl1 vl
)
710 (while (string-match "|" line start
)
711 (setq start
(match-end 0))
712 (or (pop vl1
) (setq line
(replace-match " " t t line
)))))
716 (defun org-colgroup-info-to-vline-list (info)
719 (setq last new new
(pop info
))
720 (if (or (memq last
'(:end
:startend
))
721 (memq new
'(:start
:startend
)))
724 (setq vl
(nreverse vl
))
725 (and vl
(setcar vl nil
))
731 ;; generated-autoload-file: "org-loaddefs.el"
734 ;;; org-ascii.el ends here