summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2025-08-21 19:22:27 -0500
committerCraig Jennings <c@cjennings.net>2025-08-21 19:22:27 -0500
commitd8ab62d791846870452438882c69ac84d35d58c7 (patch)
tree2e0347412e2864c5a397576fac3d50cad99b96d1 /modules
parent685a2b68e36d5f4d2b2d9dfc7b8232317ccae331 (diff)
downloaddotemacs-d8ab62d791846870452438882c69ac84d35d58c7.tar.gz
dotemacs-d8ab62d791846870452438882c69ac84d35d58c7.zip
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
Diffstat (limited to 'modules')
-rw-r--r--modules/org-export-config.el80
1 files changed, 60 insertions, 20 deletions
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 "<style type=\"text/css\">\n%s\n</style>" 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 <span class=\"todo …\">TODO</span> from a single TOC entry."
+ (when (eq backend 'html)
+ (replace-regexp-in-string
+ "<span class=\"todo [^\"]*\">[^<]*</span>[[: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.