소스 검색

ob-gnuplot: Use org backend when assigning table to variable

* lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Switch to 'org
backend when exporting table data to plain text table.  ascii backend
incorrectly handles quote transcoders that change the column width and
sometimes throws an error.  (ascii backend simply ignores transcoded
table cells and calculates width based on the initial cell text).
Ihor Radchenko 3 년 전
부모
커밋
c614234688
1개의 변경된 파일15개의 추가작업 그리고 5개의 파일을 삭제
  1. 15 5
      lisp/ob-gnuplot.el

+ 15 - 5
lisp/ob-gnuplot.el

@@ -287,11 +287,21 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting TABLE."
   (with-temp-file data-file
     (insert (let ((org-babel-gnuplot-timestamp-fmt
 		   (or (plist-get params :timefmt) "%Y-%m-%d-%H:%M:%S")))
-	      (orgtbl-to-generic
-	       table
-	       (org-combine-plists
-		'(:sep "\t" :fmt org-babel-gnuplot-quote-tsv-field :raw t :backend ascii)
-		params)))))
+              (replace-regexp-in-string
+               ;; org export backend adds "|" at the beginning/end of
+               ;; the table lines.  Strip those.
+               "^|\\(.+\\)|$"
+               "\\1"
+	       (orgtbl-to-generic
+	        table
+	        (org-combine-plists
+		 '( :sep "\t" :fmt org-babel-gnuplot-quote-tsv-field
+                    ;; Two setting below are needed to make :fmt work.
+                    :raw t
+                    ;; Use `org', not `ascii' because `ascii' may
+                    ;; sometimes mishandle quoted strings.
+                    :backend org)
+		 params))))))
   data-file)
 
 (provide 'ob-gnuplot)