38 lines
1.4 KiB
Org Mode
38 lines
1.4 KiB
Org Mode
:PROPERTIES:
|
|
:ID: cce/org_html_css_inclusion
|
|
:ROAM_ALIASES: "Org HTML CSS Inclusion"
|
|
:END:
|
|
#+TITLE: Embed CSS in Org-Mode HTML Exports
|
|
#+PROPERTY: header-args :mkdirp yes :results none
|
|
#+PROPERTY: header-args:emacs-lisp :tangle org-html-css.el
|
|
#+ARROYO_EMACS_MODULE: org-html-css
|
|
#+ARCOLOGY_KEY: cce/org-html-css
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
#+CCE_PRIORITY: 45
|
|
#+ARROYO_MODULE_WANTS: cce/org_mode_installation.org
|
|
|
|
We insert a CSS file in to the files I =org-export=.
|
|
|
|
#+begin_src emacs-lisp
|
|
(defun cce/org-inline-css-hook (exporter)
|
|
"Insert custom inline css"
|
|
(when (eq exporter 'html)
|
|
(let* ((dir (ignore-errors (file-name-directory (buffer-file-name))))
|
|
(path (concat dir "style.css"))
|
|
(homestyle (or (null dir) (null (file-exists-p path))))
|
|
(final (if homestyle "~/org/style.css" path))) ;; <- set your own style file path
|
|
(setq org-html-head-include-default-style nil)
|
|
(setq org-html-head (concat
|
|
"<style type=\"text/css\">\n"
|
|
"<!--/*--><![CDATA[/*><!--*/\n"
|
|
(with-temp-buffer
|
|
(insert-file-contents final)
|
|
(buffer-string))
|
|
"/*]]>*/-->\n"
|
|
"</style>\n")))))
|
|
|
|
(add-hook 'org-export-before-processing-hook 'cce/org-inline-css-hook)
|
|
#+end_src
|
|
|
|
|