diff --git a/oni-org/oni-org.el b/oni-org/oni-org.el index fab80b2..9dbad99 100644 --- a/oni-org/oni-org.el +++ b/oni-org/oni-org.el @@ -4,7 +4,7 @@ ;; Author: Tom Willemse ;; Keywords: local -;; Version: 2021.0630.150728 +;; Version: 2021.0701.185951 ;; Package-Requires: (oni-yasnippet oni-alert oni-hydra org org-contrib org-bullets org-edna diminish all-the-icons olivetti) ;; This program is free software; you can redistribute it and/or modify @@ -580,5 +580,41 @@ After running it once remove it from `org-capture-after-finalize-hook'." (setq org-refile-targets '((nil . (:maxlevel . 10)) (org-default-notes-file . (:maxlevel . 10)))) +;;; Export +(require 'ox-html) +(require 'nxml-mode) + +;; From https://emacs.stackexchange.com/a/57433 +(defcustom oni-org-html-embed-svg nil + "Embed SVG images. +You can set this variable in Org files with +#+HTML_EMBED_SVG: t +or +#+OPTIONS: html-embed-svg:t" + :type 'boolean + :group 'org-export-html) + +(cl-pushnew + '(:html-embed-svg "HTML_EMBED_SVG" "html-embed-svg" oni-org-html-embed-svg) + (org-export-backend-options (org-export-get-backend 'html))) + +(defun oni-org-html-svg-image-embed (fun source attributes info) + "Make embedding of SVG images possible in org HTML export. +SVG images are embedded if :html-embed-svg is non-nil in the plist INFO. +Otherwise FUN called with SOURCE, ATTRIBUTES, and INFO as arguments. +SOURCE is the file name of the SVG file. +This is an around advice for ‘org-html--svg-image’ as FUN." + (if (member (plist-get info :html-embed-svg) '("yes" "t" t)) + (with-temp-buffer + (insert-file-contents source) + (with-syntax-table nxml-mode-syntax-table + (while (and (search-forward "