From 7e7a5dca5deb0526f4d58729857371b87edb4bc0 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Sat, 6 Mar 2021 19:06:54 +0100 Subject: [PATCH] add html export to custom artcle --- lisp/my/my-org-article.el | 742 +++++++++++++++++++++++++++++++++++++- 1 file changed, 736 insertions(+), 6 deletions(-) diff --git a/lisp/my/my-org-article.el b/lisp/my/my-org-article.el index ad29a70d..7ef0d6d9 100644 --- a/lisp/my/my-org-article.el +++ b/lisp/my/my-org-article.el @@ -7,24 +7,26 @@ ;; # -*- ispell-local-dictionary: "german" -*- ;; #+LANGUAGE: en ;; #+TITLE: Emacs -;; #+SUBTITLE: +;; #+SUBTITLE: ;; #+AUTHOR: Daniel Weschke ;; #+EMAIL: daniel.weschke@directbox.de ;; #+DATE: 25. November 2019 -;; #+KEYWORDS: -;; #+DESCRIPTION: +;; #+KEYWORDS: +;; #+DESCRIPTION: ;; * Header :ignore: ;;; Code: -(require 'ox-latex) (require 'ob-latex) (require 'ob-gnuplot) +(require 'ox-latex) +(require 'ox-tufte) ;;(setq org-babel-latex-htlatex "htlualatex") ;;(setq org-babel-latex-htlatex "htlatex") ;; (executable-find org-babel-latex-htlatex) +;; Babel latex and gnuplot ;; PROPERTY src block header arguments https://orgmode.org/manual/Property-Syntax.html ;; https://orgmode.org/manual/Using-Header-Arguments.html ;; on src block C-c C-v I - org-babel-view-src-block-info this will eval as org backend @@ -162,8 +164,7 @@ (:article-references "REFERENCES" nil my-org-article-latex-references newline)) :translate-alist - '((template . my-org-article-latex-template)) - ) + '((template . my-org-article-latex-template))) ;;; User Configurable Variables @@ -2157,5 +2158,734 @@ default." async subtreep visible-only body-only ext-plist (lambda (file) (org-latex-compile file))))) + +;; HTML +(org-export-define-derived-backend 'article-html 'tufte-html + + :menu-entry + '(?h ?a + ((?a "To HTML file" my-org-article-html-export-to-html) + (?A "To HTML file and open" + (lambda (a s v b) + (if a (my-org-article-html-export-to-html t s v b) + (org-open-file (my-org-article-html-export-to-html nil s v b))))))) + + :options-alist + '((:html-doctype "HTML_DOCTYPE" nil my-org-article-html-doctype) + (:html-head "HTML_HEAD" nil my-org-article-html-head newline)) + + ;;:translate-alist + ;;'((template . my-org-article-html-template)) + ) + + +;;; User Configuration Variables + +;;;; Template :: Generic + +(defcustom my-org-article-html-doctype "html5" + "See `org-html-doctype'." + :group 'my-org-export-article + :version "24.4" + :package-version '(Org . "8.0") + :type (append + '(choice) + (mapcar (lambda (x) `(const ,(car x))) org-html-doctype-alist) + '((string :tag "Custom doctype" )))) + +;;;; Template :: Styles + +(defcustom my-org-article-html-head " + +" + "See `org-html-head'." + :group 'my-org-export-article + :version "24.4" + :package-version '(Org . "8.0") + :type 'string) +;;;###autoload +(put 'org-html-head 'safe-local-variable 'stringp) + + +;;; Export functions + +;;;###autoload +(defun my-org-article-html-export-to-html (&optional async subtreep visible-only body-only ext-plist) + "See `org-tufte-export-to-file' and `org-html-export-to-html'." + (interactive) + (let* ((extension (concat + (when (> (length org-html-extension) 0) ".") + (or (plist-get ext-plist :html-extension) + org-html-extension + "html"))) + (file (org-export-output-file-name extension subtreep)) + ;; need to bind this because tufte treats footnotes specially, so we + ;; don't want to display them at the bottom + (org-html-footnotes-section (if org-tufte-include-footnotes-at-bottom + org-html-footnotes-section + ""))) + (org-export-to-file 'article-html file async subtreep + visible-only body-only ext-plist))) + (provide 'my-org-article) ;;; my-org-article.el ends here