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
93 (defun org-export-as-latin1 (&rest args
)
94 "Like `org-export-as-ascii', use latin1 encoding for special symbols."
96 (org-export-as-encoding 'org-export-as-ascii
(org-called-interactively-p 'any
)
99 (defun org-export-as-latin1-to-buffer (&rest args
)
100 "Like `org-export-as-ascii-to-buffer', use latin1 encoding for symbols."
102 (org-export-as-encoding 'org-export-as-ascii-to-buffer
103 (org-called-interactively-p 'any
) 'latin1 args
))
105 (defun org-export-as-utf8 (&rest args
)
106 "Like `org-export-as-ascii', use encoding for special symbols."
108 (org-export-as-encoding 'org-export-as-ascii
109 (org-called-interactively-p 'any
)
112 (defun org-export-as-utf8-to-buffer (&rest args
)
113 "Like `org-export-as-ascii-to-buffer', use utf8 encoding for symbols."
115 (org-export-as-encoding 'org-export-as-ascii-to-buffer
116 (org-called-interactively-p 'any
) 'utf8 args
))
118 (defun org-export-as-encoding (command interactivep encoding
&rest args
)
119 (let ((org-export-ascii-entities encoding
))
121 (call-interactively command
)
122 (apply command args
))))
125 (defun org-export-as-ascii-to-buffer (arg)
126 "Call `org-export-as-ascii` with output to a temporary buffer.
127 No file is created. The prefix ARG is passed through to `org-export-as-ascii'."
129 (org-export-as-ascii arg nil
"*Org ASCII Export*")
130 (when org-export-show-temporary-export-buffer
131 (switch-to-buffer-other-window "*Org ASCII Export*")))
133 (defun org-replace-region-by-ascii (beg end
)
134 "Assume the current region has org-mode syntax, and convert it to plain ASCII.
135 This can be used in any buffer. For example, you could write an
136 itemized list in org-mode syntax in a Mail buffer and then use this
137 command to convert it."
139 (let (reg ascii buf pop-up-frames
)
140 (save-window-excursion
141 (if (derived-mode-p 'org-mode
)
142 (setq ascii
(org-export-region-as-ascii
144 (setq reg
(buffer-substring beg end
)
145 buf
(get-buffer-create "*Org tmp*"))
146 (with-current-buffer buf
150 (setq ascii
(org-export-region-as-ascii
151 (point-min) (point-max) t
'string
)))
153 (delete-region beg end
)
156 (defun org-export-region-as-ascii (beg end
&optional body-only buffer
)
157 "Convert region from BEG to END in org-mode buffer to plain ASCII.
158 If prefix arg BODY-ONLY is set, omit file header, footer, and table of
159 contents, and only produce the region of converted text, useful for
160 cut-and-paste operations.
161 If BUFFER is a buffer or a string, use/create that buffer as a target
162 of the converted ASCII. If BUFFER is the symbol `string', return the
163 produced ASCII as a string and leave not buffer behind. For example,
164 a Lisp program could call this function in the following way:
166 (setq ascii (org-export-region-as-ascii beg end t 'string))
168 When called interactively, the output buffer is selected, and shown
169 in a window. A non-interactive call will only return the buffer."
171 (when (org-called-interactively-p 'any
)
172 (setq buffer
"*Org ASCII Export*"))
173 (let ((transient-mark-mode t
) (zmacs-regions t
)
175 (setq ext-plist
(plist-put ext-plist
:ignore-subtree-p t
))
177 (set-mark (point)) ;; to activate the region
179 (setq rtn
(org-export-as-ascii nil ext-plist buffer body-only
))
180 (if (fboundp 'deactivate-mark
) (deactivate-mark))
181 (if (and (org-called-interactively-p 'any
) (bufferp rtn
))
182 (switch-to-buffer-other-window rtn
)
185 (defun org-export-as-ascii (arg &optional ext-plist to-buffer body-only pub-dir
)
186 "Export the outline as a pretty ASCII file.
187 If there is an active region, export only the region.
188 The prefix ARG specifies how many levels of the outline should become
189 underlined headlines, default is 3. Lower levels will become bulleted
190 lists. EXT-PLIST is a property list with external parameters overriding
191 org-mode's default settings, but still inferior to file-local
192 settings. When TO-BUFFER is non-nil, create a buffer with that
193 name and export to that buffer. If TO-BUFFER is the symbol
194 `string', don't leave any buffer behind but just return the
195 resulting ASCII as a string. When BODY-ONLY is set, don't produce
196 the file header and footer. When PUB-DIR is set, use this as the
197 publishing directory."
199 (run-hooks 'org-export-first-hook
)
200 (setq-default org-todo-line-regexp org-todo-line-regexp
)
201 (let* ((opt-plist (org-combine-plists (org-default-export-plist)
203 (org-infile-export-plist)))
204 (region-p (org-region-active-p))
205 (rbeg (and region-p
(region-beginning)))
206 (rend (and region-p
(region-end)))
208 (if (plist-get opt-plist
:ignore-subtree-p
)
213 (and (org-at-heading-p)
214 (>= (org-end-of-subtree t t
) rend
))))))
215 (level-offset (if subtree-p
218 (+ (funcall outline-level
)
219 (if org-odd-levels-only
1 0)))
221 (opt-plist (setq org-export-opt-plist
223 (org-export-add-subtree-options opt-plist rbeg
)
225 ;; The following two are dynamically scoped into other
227 (org-current-export-dir
228 (or pub-dir
(org-export-directory :html opt-plist
)))
229 (org-current-export-file buffer-file-name
)
230 (custom-times org-display-custom-times
)
231 (org-ascii-current-indentation '(0 .
0))
235 (case-fold-search nil
)
236 (bfname (buffer-file-name (or (buffer-base-buffer) (current-buffer))))
237 (filename (if to-buffer
239 (concat (file-name-as-directory
241 (org-export-directory :ascii opt-plist
)))
242 (file-name-sans-extension
244 (org-entry-get (region-beginning)
245 "EXPORT_FILE_NAME" t
))
246 (file-name-nondirectory bfname
)))
248 (filename (and filename
249 (if (equal (file-truename filename
)
250 (file-truename bfname
))
251 (concat filename
".txt")
253 (buffer (if to-buffer
255 ((eq to-buffer
'string
)
256 (get-buffer-create "*Org ASCII Export*"))
257 (t (get-buffer-create to-buffer
)))
258 (find-file-noselect filename
)))
259 (org-levels-open (make-vector org-level-max nil
))
260 (odd org-odd-levels-only
)
261 (date (plist-get opt-plist
:date
))
262 (author (plist-get opt-plist
:author
))
263 (title (or (and subtree-p
(org-export-get-title-from-subtree))
264 (plist-get opt-plist
:title
)
266 (plist-get opt-plist
:skip-before-1st-heading
))
267 (org-export-grab-title-from-buffer))
268 (and (buffer-file-name)
269 (file-name-sans-extension
270 (file-name-nondirectory bfname
)))
272 (email (plist-get opt-plist
:email
))
273 (language (plist-get opt-plist
:language
))
274 (quote-re0 (concat "^\\(" org-quote-string
"\\)\\( +\\|[ \t]*$\\)"))
279 (if (org-region-active-p) (region-beginning) (point-min))
280 (if (org-region-active-p) (region-end) (point-max))))
281 (org-export-footnotes-seen nil
)
282 (org-export-footnotes-data (org-footnote-all-labels 'with-defs
))
283 (lines (org-split-string
284 (org-export-preprocess-string
287 :skip-before-1st-heading
288 (plist-get opt-plist
:skip-before-1st-heading
)
289 :drawers
(plist-get opt-plist
:drawers
)
290 :tags
(plist-get opt-plist
:tags
)
291 :priority
(plist-get opt-plist
:priority
)
292 :footnotes
(plist-get opt-plist
:footnotes
)
293 :timestamps
(plist-get opt-plist
:timestamps
)
294 :todo-keywords
(plist-get opt-plist
:todo-keywords
)
295 :tasks
(plist-get opt-plist
:tasks
)
296 :verbatim-multiline t
297 :select-tags
(plist-get opt-plist
:select-tags
)
298 :exclude-tags
(plist-get opt-plist
:exclude-tags
)
300 (plist-get opt-plist
:archived-trees
)
301 :add-text
(plist-get opt-plist
:text
))
303 thetoc have-headings first-heading-pos
304 table-open table-buffer link-buffer link type path desc desc0 rpl wrap fnc
)
305 (let ((inhibit-read-only t
))
307 (remove-text-properties (point-min) (point-max)
308 '(:org-license-to-kill t
))))
310 (setq org-min-level
(org-get-min-level lines level-offset
))
311 (setq org-last-level org-min-level
)
312 (org-init-section-numbers)
313 (setq lang-words
(or (assoc language org-export-language-setup
)
314 (assoc "en" org-export-language-setup
)))
318 (org-install-letbind)
319 ;; create local variables for all options, to make sure all called
320 ;; functions get the correct information
322 (set (make-local-variable (nth 2 x
))
323 (plist-get opt-plist
(car x
))))
324 org-export-plist-vars
)
325 (org-set-local 'org-odd-levels-only odd
)
326 (setq umax
(if arg
(prefix-numeric-value arg
)
327 org-export-headline-levels
))
328 (setq umax-toc
(if (integerp org-export-with-toc
)
329 (min org-export-with-toc umax
)
334 (when (and title
(not (string= "" title
)))
335 (org-insert-centered title ?
=)
338 (if (and (or author email
)
339 org-export-author-info
)
340 (insert (concat (nth 1 lang-words
) ": " (or author
"")
341 (if (and org-export-email-info
342 email
(string-match "\\S-" email
))
343 (concat " <" email
">") "")
347 ((and date
(string-match "%" date
))
348 (setq date
(format-time-string date
)))
350 (t (setq date
(format-time-string "%Y-%m-%d %T %Z"))))
352 (if (and date org-export-time-stamp-file
)
353 (insert (concat (nth 2 lang-words
) ": " date
"\n")))
355 (unless (= (point) (point-min))
358 (if (and org-export-with-toc
(not body-only
))
360 (push (concat (nth 3 lang-words
) "\n") thetoc
)
361 (push (concat (make-string (string-width (nth 3 lang-words
)) ?
=)
363 (mapc #'(lambda (line)
364 (if (string-match org-todo-line-regexp
366 ;; This is a headline
368 (setq have-headings t
)
369 (setq level
(- (match-end 1) (match-beginning 1)
371 level
(org-tr-level level
)
372 txt
(match-string 3 line
)
374 (or (and org-export-mark-todo-in-toc
376 (not (member (match-string 2 line
)
379 (and org-export-mark-todo-in-toc
381 (org-search-todo-below
383 (setq txt
(org-html-expand-for-ascii txt
))
385 (while (string-match org-bracket-link-regexp txt
)
388 (match-string (if (match-end 2) 3 1) txt
)
391 (if (and (memq org-export-with-tags
'(not-in-toc nil
))
393 (org-re "[ \t]+:[[:alnum:]_@#%:]+:[ \t]*$")
395 (setq txt
(replace-match "" t t txt
)))
396 (if (string-match quote-re0 txt
)
397 (setq txt
(replace-match "" t t txt
1)))
399 (if org-export-with-section-numbers
400 (setq txt
(concat (org-section-number level
)
402 (if (<= level umax-toc
)
407 (* (max 0 (- level org-min-level
)) 4) ?\
)
408 (format (if todo
"%s (*)\n" "%s\n") txt
))
410 (setq org-last-level level
))
413 (setq thetoc
(if have-headings
(nreverse thetoc
) nil
))))
415 (org-init-section-numbers)
416 (while (setq line
(pop lines
))
417 (when (and link-buffer
(string-match org-outline-regexp-bol line
))
418 (org-export-ascii-push-links (nreverse link-buffer
))
419 (setq link-buffer nil
))
421 ;; Remove the quoted HTML tags.
422 (setq line
(org-html-expand-for-ascii line
))
423 ;; Replace links with the description when possible
424 (while (string-match org-bracket-link-analytic-regexp
++ line
)
425 (setq path
(match-string 3 line
)
426 link
(concat (match-string 1 line
) path
)
427 type
(match-string 2 line
)
428 desc0
(match-string 5 line
)
429 desc0
(replace-regexp-in-string "\\\\_" "_" desc0
)
431 desc
(replace-regexp-in-string "\\\\_" "_" desc
))
432 (if (and (> (length link
) 8)
433 (equal (substring link
0 8) "coderef:"))
434 (setq line
(replace-match
435 (format (org-export-get-coderef-format (substring link
8) desc
)
438 org-export-code-refs
)))
440 (setq rpl
(concat "[" desc
"]"))
441 (if (functionp (setq fnc
(nth 2 (assoc type org-link-protocols
))))
442 (setq rpl
(or (save-match-data
443 (funcall fnc
(org-link-unescape path
)
446 (when (and desc0
(not (equal desc0 link
)))
447 (if org-export-ascii-links-to-notes
448 (push (cons desc0 link
) link-buffer
)
449 (setq rpl
(concat rpl
" (" link
")")
450 wrap
(+ (length line
) (- (length (match-string 0 line
)))
452 (setq line
(replace-match rpl t t line
))))
454 (setq line
(org-translate-time line
)))
456 ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line
)
458 (setq first-heading-pos
(or first-heading-pos
(point)))
459 (setq level
(org-tr-level (- (match-end 1) (match-beginning 1)
461 txt
(match-string 2 line
))
462 (org-ascii-level-start level txt umax lines
))
464 ((and org-export-with-tables
465 (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)" line
))
468 (setq table-open t table-buffer nil
))
470 (setq table-buffer
(cons line table-buffer
))
471 (when (or (not lines
)
472 (not (string-match "^\\([ \t]*\\)\\(|\\|\\+-+\\+\\)"
475 table-buffer
(nreverse table-buffer
))
478 (org-fix-indentation x org-ascii-current-indentation
))
479 (org-format-table-ascii table-buffer
)
482 (if (string-match "^\\([ \t]*\\)\\([-+*][ \t]+\\)\\(.*?\\)\\( ::\\)"
484 (setq line
(replace-match "\\1\\3:" t nil line
)))
485 (setq line
(org-fix-indentation line org-ascii-current-indentation
))
486 ;; Remove forced line breaks
487 (if (string-match "\\\\\\\\[ \t]*$" line
)
488 (setq line
(replace-match "" t t line
)))
489 (if (and org-export-with-fixed-width
490 (string-match "^\\([ \t]*\\)\\(:\\( \\|$\\)\\)" line
))
491 (setq line
(replace-match "\\1" nil nil line
))
492 (if wrap
(setq line
(org-export-ascii-wrap line wrap
))))
493 (insert line
"\n"))))
495 (org-export-ascii-push-links (nreverse link-buffer
))
499 ;; insert the table of contents
501 (goto-char (point-min))
502 (if (re-search-forward "^[ \t]*\\[TABLE-OF-CONTENTS\\][ \t]*$" nil t
)
504 (goto-char (match-beginning 0))
506 (goto-char first-heading-pos
))
507 (mapc 'insert thetoc
)
508 (or (looking-at "[ \t]*\n[ \t]*\n")
511 ;; Convert whitespace place holders
512 (goto-char (point-min))
514 (while (setq beg
(next-single-property-change (point) 'org-whitespace
))
515 (setq end
(next-single-property-change beg
'org-whitespace
))
517 (delete-region beg end
)
518 (insert (make-string (- end beg
) ?\
))))
520 ;; remove display and invisible chars
522 (goto-char (point-min))
523 (while (setq beg
(next-single-property-change (point) 'display
))
524 (setq end
(next-single-property-change beg
'display
))
525 (delete-region beg end
)
528 (goto-char (point-min))
529 (while (setq beg
(next-single-property-change (point) 'org-cwidth
))
530 (setq end
(next-single-property-change beg
'org-cwidth
))
531 (delete-region beg end
)
533 (run-hooks 'org-export-ascii-final-hook
)
534 (or to-buffer
(save-buffer))
535 (goto-char (point-min))
536 (or (org-export-push-to-kill-ring "ASCII")
537 (message "Exporting... done"))
538 ;; Return the buffer or a string, according to how this function was called
539 (if (eq to-buffer
'string
)
540 (prog1 (buffer-substring (point-min) (point-max))
541 (kill-buffer (current-buffer)))
544 (defun org-export-ascii-preprocess (parameters)
545 "Do extra work for ASCII export."
547 ;; Realign tables to get rid of narrowing
548 (when org-export-ascii-table-widen-columns
549 (let ((org-table-do-narrow nil
))
550 (goto-char (point-min))
551 (org-ascii-replace-entities)
552 (goto-char (point-min))
553 (org-table-map-tables
554 (lambda () (org-if-unprotected (org-table-align)))
556 ;; Put quotes around verbatim text
557 (goto-char (point-min))
558 (while (re-search-forward org-verbatim-re nil t
)
559 (org-if-unprotected-at (match-beginning 4)
560 (goto-char (match-end 2))
561 (backward-delete-char 1) (insert "'")
562 (goto-char (match-beginning 2))
563 (delete-char 1) (insert "`")
564 (goto-char (match-end 2))))
565 ;; Remove target markers
566 (goto-char (point-min))
567 (while (re-search-forward "<<<?\\([^<>]*\\)>>>?\\([ \t]*\\)" nil t
)
568 (org-if-unprotected-at (match-beginning 1)
569 (replace-match "\\1\\2")))
570 ;; Remove list start counters
571 (goto-char (point-min))
572 (while (org-list-search-forward
573 "\\[@\\(?:start:\\)?\\([0-9]+\\|[A-Za-z]\\)\\][ \t]*" nil t
)
575 (remove-text-properties
576 (point-min) (point-max)
577 '(face nil font-lock-fontified nil font-lock-multiline nil line-prefix nil wrap-prefix nil
)))
579 (defun org-html-expand-for-ascii (line)
580 "Handle quoted HTML for ASCII export."
581 (if org-export-html-expand
582 (while (string-match "@<[^<>\n]*>" line
)
583 ;; We just remove the tags for now.
584 (setq line
(replace-match "" nil nil line
))))
587 (defun org-ascii-replace-entities ()
588 "Replace entities with the ASCII representation."
590 (while (re-search-forward "\\\\\\([a-zA-Z]+[0-9]*\\)\\({}\\)?" nil t
)
591 (org-if-unprotected-at (match-beginning 1)
592 (setq e
(org-entity-get-representation (match-string 1)
593 org-export-ascii-entities
))
594 (and e
(replace-match e t t
))))))
596 (defun org-export-ascii-wrap (line where
)
597 "Wrap LINE at or before WHERE."
598 (let ((ind (org-get-indentation line
))
601 (loop for i from where downto
(/ where
2) do
602 (and (equal (aref line i
) ?\
)
606 (concat (substring line
0 pos
) "\n"
607 (make-string ind ?\
)
608 (substring line
(1+ pos
)))
611 (defun org-export-ascii-push-links (link-buffer)
612 "Push out links in the buffer."
614 ;; We still have links to push out.
620 (concat "^\\(\\([ \t]*\\)\\|\\("
622 "\\)\\)[^ \t\n]") nil t
))
623 (setq ind
(or (match-string 2)
624 (make-string (length (match-string 3)) ?\
)))))
625 (mapc (lambda (x) (insert ind
"[" (car x
) "]: " (cdr x
) "\n"))
629 (defun org-ascii-level-start (level title umax
&optional lines
)
630 "Insert a new level in ASCII export."
631 (let (char (n (- level umax
1)) (ind 0))
634 (insert (make-string (* 2 n
) ?\
)
635 (char-to-string (nth (% n
(length org-export-ascii-bullets
))
636 org-export-ascii-bullets
))
638 ;; find the indentation of the next non-empty line
641 (if (string-match "^\\* " (car lines
)) (throw 'stop nil
))
642 (if (string-match "^\\([ \t]*\\)\\S-" (car lines
))
643 (throw 'stop
(setq ind
(org-get-indentation (car lines
)))))
645 (setq org-ascii-current-indentation
(cons (* 2 (1+ n
)) ind
)))
646 (if (or (not (equal (char-before) ?
\n))
647 (not (equal (char-before (1- (point))) ?
\n)))
649 (setq char
(or (nth (1- level
) org-export-ascii-underline
)
650 (car (last org-export-ascii-underline
))))
651 (unless org-export-with-tags
652 (if (string-match (org-re "[ \t]+\\(:[[:alnum:]_@#%:]+:\\)[ \t]*$") title
)
653 (setq title
(replace-match "" t t title
))))
654 (if org-export-with-section-numbers
655 (setq title
(concat (org-section-number level
) " " title
)))
656 (insert title
"\n" (make-string (string-width title
) char
) "\n")
657 (setq org-ascii-current-indentation
'(0 .
0)))))
659 (defun org-insert-centered (s &optional underline
)
660 "Insert the string S centered and underline it with character UNDERLINE."
661 (let ((ind (max (/ (- fill-column
(string-width s
)) 2) 0)))
662 (insert (make-string ind ?\
) s
"\n")
664 (insert (make-string ind ?\
)
665 (make-string (string-width s
) underline
)
668 (defvar org-table-colgroup-info nil
)
669 (defun org-format-table-ascii (lines)
670 "Format a table for ascii export."
672 (setq lines
(org-split-string lines
"\n")))
673 (if (not (string-match "^[ \t]*|" (car lines
)))
674 ;; Table made by table.el - test for spanning
677 ;; A normal org table
678 ;; Get rid of hlines at beginning and end
679 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
680 (setq lines
(nreverse lines
))
681 (if (string-match "^[ \t]*|-" (car lines
)) (setq lines
(cdr lines
)))
682 (setq lines
(nreverse lines
))
683 (when org-export-table-remove-special-lines
684 ;; Check if the table has a marking column. If yes remove the
685 ;; column and the special lines
686 (setq lines
(org-table-clean-before-export lines
)))
687 ;; Get rid of the vertical lines except for grouping
688 (if org-export-ascii-table-keep-all-vertical-lines
690 (let ((vl (org-colgroup-info-to-vline-list org-table-colgroup-info
))
692 (while (setq line
(pop lines
))
693 (if (string-match org-table-hline-regexp line
)
694 (and (string-match "|\\(.*\\)|" line
)
695 (setq line
(replace-match " \\1" t nil line
)))
696 (setq start
0 vl1 vl
)
697 (while (string-match "|" line start
)
698 (setq start
(match-end 0))
699 (or (pop vl1
) (setq line
(replace-match " " t t line
)))))
703 (defun org-colgroup-info-to-vline-list (info)
706 (setq last new new
(pop info
))
707 (if (or (memq last
'(:end
:startend
))
708 (memq new
'(:start
:startend
)))
711 (setq vl
(nreverse vl
))
712 (and vl
(setcar vl nil
))
720 ;;; org-ascii.el ends here