> On Aug 28, 2019, at 5:59 PM, Michaël Cadilhac <mich...@cadilhac.name> wrote:
> My goal is to export SVG files of TikZ drawings in HTML.  Now, what follows 
> is a bit of a rant on `org-babel-execute:latex`; let's go through the options:
> -

Well you can try to continue on your path, but it can get `interesting'.

An alternative is to do something like this:

Define an export backend that derives from 'html. 

Flesh out the function `org-tikz-html-export-block' to process the content of 
`tikz' export blocks to render the derived SVG. Use existing functions in 
`ox-latex.el' as helpers if that works.

#+begin_src emacs-lisp
  (org-export-define-derived-backend 'tikz-html 'html
    :translate-alist '((export-block . org-tikz-html-export-block)))

  (defun org-tikz-html-export-block (export-block contents info)
    "Transcoder to TikZ in html exports."
    (when (string= (org-element-property :type export-block) "TIKZ")
      (let ((tikz-code 
              (org-element-property :value export-block))))
        ;; process TikZ code to SVG
        ;; produce a suitable link to include the SVG as the result

Then blocks like

#+begin_export tikz
% tikz code goes here

should render when you run

#+begin_src emacs-lisp
  (org-export-to-file 'tikz-html "file-name.html") 

You might adapt `org-html-export-to-html' if the features it offers are needed 
and add a :menu-entry to enable running from the export dispatcher under the 
html choices.




Reply via email to