emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org d38ca59230 2/2: ob-gnuplot: Fix links and verbatim


From: ELPA Syncer
Subject: [elpa] externals/org d38ca59230 2/2: ob-gnuplot: Fix links and verbatim when converting tables
Date: Sat, 29 Jul 2023 06:58:19 -0400 (EDT)

branch: externals/org
commit d38ca59230bd3b013398376c46719694948fe31e
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>

    ob-gnuplot: Fix links and verbatim when converting tables
    
    * lisp/ob-gnuplot.el (org-babel-gnuplot-table-to-data): Use custom
    backend to export table data.  The backend will export links verbatim,
    without trying to resolve them and drop verbatim markers from data
    fields.
    
    Reported-by: Paul Stansell <paulstansell@gmail.com>
    Link: 
https://orgmode.org/list/CAMJKaZzHuLxPoTg6FWUgt-U8QSHmuB3Kdqmk_E_0GH+jUZMSag@mail.gmail.com
---
 lisp/ob-gnuplot.el | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/lisp/ob-gnuplot.el b/lisp/ob-gnuplot.el
index 8152a04520..91e4bed89a 100644
--- a/lisp/ob-gnuplot.el
+++ b/lisp/ob-gnuplot.el
@@ -45,6 +45,7 @@
 
 (require 'ob)
 (require 'org-macs)
+(require 'ox-ascii)
 
 (declare-function org-time-string-to-time "org" (s))
 (declare-function orgtbl-to-generic "org-table" (table params))
@@ -295,14 +296,29 @@ Pass PARAMS through to `orgtbl-to-generic' when exporting 
TABLE."
   (require 'ox-org)
   (with-temp-file data-file
     (insert (let ((org-babel-gnuplot-timestamp-fmt
-                  (or (plist-get params :timefmt) "%Y-%m-%d-%H:%M:%S")))
+                  (or (plist-get params :timefmt) "%Y-%m-%d-%H:%M:%S"))
+                  ;; Create custom limited backend that will disable
+                  ;; advanced ASCII export features that may alter the
+                  ;; original data.
+                  (ob-gnuplot-data
+                   (org-export-create-backend
+                    :parent 'ascii
+                    :transcoders
+                    `(;; Do not try to resolve links.  Export them verbatim.
+                      (link . (lambda (link _ _) (org-element-interpret-data 
link)))
+                      ;; Drop emphasis markers from verbatim and code.
+                      ;; This way, data can use verbatim when escaping
+                      ;; is necessary and yet be readable by Gnuplot,
+                      ;; which is not aware about Org's markup.
+                      (verbatim . (lambda (verbatim _ _) (org-element-property 
:value verbatim)))
+                      (code . (lambda (code _ _) (org-element-property :value 
code)))))))
              (orgtbl-to-generic
               table
               (org-combine-plists
-               '( :sep "\t" :fmt org-babel-gnuplot-quote-tsv-field
+               `( :sep "\t" :fmt org-babel-gnuplot-quote-tsv-field
                    ;; Two setting below are needed to make :fmt work.
                    :raw t
-                   :backend ascii)
+                   :backend ,ob-gnuplot-data)
                params)))))
   data-file)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]