[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] HTML export with LaTeX babel blocks
From: |
Berry, Charles |
Subject: |
Re: [O] HTML export with LaTeX babel blocks |
Date: |
Thu, 29 Aug 2019 18:13:27 +0000 |
> On Aug 28, 2019, at 5:59 PM, Michaël Cadilhac <address@hidden> 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:
>
> -
[snip]
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-remove-indentation
(org-element-property :value export-block))))
;; process TikZ code to SVG
;; produce a suitable link to include the SVG as the result
)))
#+end_src
Then blocks like
#+begin_export tikz
% tikz code goes here
#+end_export
should render when you run
#+begin_src emacs-lisp
(org-export-to-file 'tikz-html "file-name.html")
#+end_src
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.
HTH,
Chuck