소스 검색

org-e-ascii: Allow to use ascii-art for table.el tables

* contrib/lisp/org-e-ascii.el (org-e-ascii-table-use-ascii-art): New
  variable.
(org-e-ascii-table): Allow to use ascii-art for table.el tables.
Nicolas Goaziou 12 년 전
부모
커밋
db004a0ad6
1개의 변경된 파일22개의 추가작업 그리고 2개의 파일을 삭제
  1. 22 2
      contrib/lisp/org-e-ascii.el

+ 22 - 2
contrib/lisp/org-e-ascii.el

@@ -243,6 +243,15 @@ Org mode, i.e. with \"=>\" as ellipsis."
   :group 'org-export-e-ascii
   :type 'boolean)
 
+(defcustom org-e-ascii-table-use-ascii-art nil
+  "Non-nil means table.el tables are turned into ascii-art.
+
+It only makes sense when export charset is `utf-8'.  It is nil by
+default since it requires ascii-art-to-unicode.el package.  You
+can download it here:
+
+  http://gnuvola.org/software/j/aa2u/ascii-art-to-unicode.el.")
+
 (defcustom org-e-ascii-caption-above nil
   "When non-nil, place caption string before the element.
 Otherwise, place it right after it."
@@ -1523,8 +1532,19 @@ contextual information."
      ;; Possibly add a caption string above.
      (when (and caption org-e-ascii-caption-above) (concat caption "\n"))
      ;; Insert table.  Note: "table.el" tables are left unmodified.
-     (if (eq (org-element-property :type table) 'org) contents
-       (org-remove-indentation (org-element-property :value table)))
+     (cond ((eq (org-element-property :type table) 'org) contents)
+	   ((and org-e-ascii-table-use-ascii-art
+		 (eq (plist-get info :ascii-charset) 'utf-8)
+		 (require 'ascii-art-to-unicode nil t))
+	    (with-temp-buffer
+	      (insert (org-remove-indentation
+		       (org-element-property :value table)))
+	      (goto-char (point-min))
+	      (aa2u)
+	      (goto-char (point-max))
+	      (skip-chars-backward " \r\t\n")
+	      (buffer-string)))
+	   (t (org-remove-indentation (org-element-property :value table))))
      ;; Possible add a caption string below.
      (when (and caption (not org-e-ascii-caption-above))
        (concat "\n" caption)))))