From d8ab62d791846870452438882c69ac84d35d58c7 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 21 Aug 2025 19:22:27 -0500 Subject: tufte.css inlined for org to html export - adding test.org and tufte.css for html exports - removed ox-pandoc from org-export-config - adjusted org-export-config to inline tufte.css instead of the default org css --- modules/org-export-config.el | 80 +++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 20 deletions(-) (limited to 'modules') diff --git a/modules/org-export-config.el b/modules/org-export-config.el index d451dd6f..6e4db7e8 100644 --- a/modules/org-export-config.el +++ b/modules/org-export-config.el @@ -19,9 +19,7 @@ ox-icalendar ox-latex ox-md - ox-odt - ox-texinfo - ox-man)) + ox-odt)) (require feat)) ;; now tell Org exactly which backends to use @@ -29,32 +27,27 @@ '(ascii beamer html - icalendar latex md - odt - org - texinfo - man)) + odt)) ;; Other Settings - (setq org-export-coding-system 'utf-8) ;; force utf-8 in org - (setq org-export-headline-levels 6) ;; export headlines 6 levels deep - (setq org-export-initial-scope 'subtree) ;; export the current subtree by default - (setq org-export-with-author nil) ;; export without author by default - (setq org-export-with-section-numbers nil) ;; export without section numbers by default - (setq org-export-with-tags nil) ;; export without tags by default - (setq org-export-with-tasks '("TODO")) ;; export with tasks by default - (setq org-export-with-toc nil)) ;; export without table of contents by default + (setq org-export-preserve-breaks t) ;; keep line breaks in all Org export back-ends + (setq org-export-coding-system 'utf-8) ;; force utf-8 in org + (setq org-export-headline-levels 6) ;; export headlines 6 levels deep + (setq org-export-initial-scope 'subtree) ;; export the current subtree by default + (setq org-export-with-author nil) ;; export without author by default + (setq org-export-with-section-numbers nil) ;; export without section numbers by default + (setq org-export-with-tags nil) ;; export without tags by default + (setq org-export-with-tasks '("TODO")) ;; export with tasks by default + ;; (setq org-export-with-tasks nil) ;; export WITHOUT tasks by default + ;; (setq org-export-with-toc nil) ;; export without table of contents by default + (setq org-export-with-toc t)) ;; export WITH table of contents by default ;; hugo markdown (use-package ox-hugo :after ox) -;; export via pandoc -(use-package ox-pandoc - :after ox) - ;; github flavored markdown (use-package ox-gfm :after ox) @@ -73,5 +66,52 @@ ;; (use-package ox-confluence ;; :after ox) +;; ------------------------------- Org Tufte CSS ------------------------------- +;; Hacks to inline a superior tufte.css style sheet into your generated html files. + +;; +;; Inline tufte.css into all generated HTML documents +;; Note: the tufte.css file in my configuration has an extra style for +;; TODO and DONE task items. +;; + +(defun cj/org-inline-css (path) + "Return the contents of the file at PATH as a string. +If the file doesn’t exist, return an empty string." + (if (file-readable-p path) + (with-temp-buffer + (insert-file-contents path) + (buffer-string)) + (progn + (message "[org-inline-css] could not read %s" path) + ""))) + +(with-eval-after-load 'ox-html + ;; Disable the postamble (footer) completely: + (setq org-html-postamble nil) + + ;; inject tufte.css from the assets folder. + (setq org-html-html5-fancy t + org-html-head-include-default-style nil + org-html-head-extra + (let* ((css-file (expand-file-name "assets/tufte.css" + user-emacs-directory)) + (css (cj/org-inline-css css-file))) + (format "" css)))) +;; +;; Don't allow Table of Contents to link to TODO items +;; +(defun cj/org-html-toc-remove-todo (toc-entry backend _info) + "Remove any TODO from a single TOC entry." + (when (eq backend 'html) + (replace-regexp-in-string + "[^<]*[[:space:]]*" + "" toc-entry))) + +(with-eval-after-load 'ox-html + ;; register our filter so each TOC line is run through it + (add-hook 'org-export-filter-toc-entry-functions + #'cj/org-html-toc-remove-todo)) + (provide 'org-export-config) ;;; org-export-config.el ends here. -- cgit v1.2.3