Authoring Content with org-mode

Revisions

This revisions table has been automatically generated from the git history of this website repository, and the change descriptions may not always be as useful as they should.

You can consult the source of this file in its current version here.

2021-03-28 2021 Spring redesign 495f9db
2021-01-24 No more syntax highlighting 1e9ac81
2020-12-12 Use Spectral Regular b340096
2020-12-10 Add a Series on coqffi, and the first literate program of this blog 2706544
2020-08-29 Start the documentation of the theme build process 23e5c85
2020-08-27 Simplify the theme b065628
2020-04-04 Benefit from cleopatra org-related functions to export org files a38a430
2020-04-02 Refactor the build process to use cleopatra the Second 46b2e7a
2020-02-27 More theme tweaking 9a0fef2
2020-02-27 Introduce a convenient Org syntax for inline maths 060c7d6
2020-02-27 Add a minimal style for the .example class used by Org for results 4d39fc4
2020-02-27 Use monokai-pro as the main theme and fix the CSS of Coq files 512e590
2020-02-27 Tweak the theme to be more responsive fbbc603
2020-02-27 Theme reloading 1a9268f
2020-02-26 Use toml-mode for syntax highlighting and align a la Cargo.toml e4659d4
2020-02-26 Display source blocks names and tangle filenames in HTML output e6cd97f
2020-02-26 Improving the end of the Bootstrapping cleopatra document af723a5
2020-02-26 Introduce a notion of dependency between generation processes 5945bc8
2020-02-24 Hide sections numbers for H4 and more in Org documents 9b8cf40
2020-02-24 Add support for JSON source block for Org documents 548b1b3
2020-02-23 Fix various typos af3ed74
2020-02-23 Reduce the length of long lines of code in cleopatra 89e27fc
2020-02-23 Try to improve the situation with overflowing source blocks af208a5
2020-02-23 Yet another attempt to only init npm and Emacs when necessary a031c80
2020-02-23 Use a softer theme bdb7137
2020-02-23 cleopatra is completely boostrapped 2869989
2020-02-23 Do not remove cleopatra files with 'make clean' 39fd0f0
2020-02-23 Provide a rule to initialize Emacs packages e5480d5
2020-02-23 Integrate the scripts and plugins used by soupault in Soupault.org 4bb8750
2020-02-23 Reworking cleopatra presentation 404d052
2020-02-22 List current generation processes and document how to add one c8a860b
2020-02-22 Use `tangle-org.el' during bootstrap d50ee0c

Author Guidelines §

Implementation §

EMACS := cleopatra-emacs

ORG_IN := $(shell find site/ -name "*.org")
ORG_OUT := $(ORG_IN:.org=.html)

org-prebuild : .emacs
org-build : ${ORG_OUT}

soupault-build : org-build

ARTIFACTS += ${ORG_OUT}
CONFIGURE += .emacs

EXPORT := --batch \
          --load="${ROOT}/scripts/packages.el" \
          --load="${ROOT}/scripts/export-org.el" \
          2>> build.log

INIT := --batch --load="${ROOT}/scripts/packages.el" \
        2>> build.log

.emacs : scripts/packages.el
	@cleopatra echo Initiating  "Emacs configuration"
	@${EMACS} ${INIT}
	@touch .emacs

%.html : %.org scripts/packages.el scripts/export-org.el \
         .emacs org.mk
	@cleopatra echo Exporting "$*.org"
	@${EMACS} $< ${EXPORT}
(use-package ox-tufte :ensure t)
(cleopatra:configure)

(org-babel-do-load-languages
 'org-babel-load-languages
 '((dot . t)
   (shell . t)))

(setq org-export-with-toc nil
      org-html-htmlize-output-type nil
      org-export-with-section-numbers nil)

(add-to-list 'org-entities-user
             '("im" "\\(" nil "<span class=\"imath\">" "" "" ""))
(add-to-list 'org-entities-user
             '("mi" "\\)" nil "</span>" "" "" ""))

(defun with-keyword (keyword k)
  "Look-up for keyword KEYWORD, and call continuation K with its value."
  (pcase (org-collect-keywords `(,keyword))
    (`((,keyword . ,kw))
     (when kw (funcall k (string-join kw " "))))))

(defun get-keyword (keyword)
  "Look-up for keyword KEYWORD, and returns its value"
  (with-keyword keyword (lambda (x) x)))

(defun get-org-title (path)
  "Fetch the title of an Org file whose path is PATH."
  (with-temp-buffer
    (find-file-read-only path)
    (get-keyword "TITLE")))

(defun insert-title ()
  "Insert the title of the article."
  (with-keyword
   "TITLE"
   (lambda (title)
     (insert
      (format "\n\n@@html:<h1>@@ %s @@html:</h1>@@\n\n" title)))))

(defun insert-series ()
  "Insert the series root link."
  (with-keyword
   "SERIES"
   (lambda (series)
     (insert "\n\n#+attr_html: :class series\n")
     (insert series))))

(defun insert-series-prev ()
  "Insert the series previous article link."
  (with-keyword
   "SERIES_PREV"
   (lambda (series-prev)
     (insert "\n\n#+attr_html: :class series-prev\n")
     (insert series-prev))))

(defun insert-series-next ()
  "Insert the series next article link."
  (with-keyword
   "SERIES_NEXT"
   (lambda (series-next)
     (insert "\n\n#+attr_html: :class series-next\n")
     (insert series-next))))

(defun insert-nav ()
  "Insert the navigation links."
  (when (get-keyword "SERIES")
    (insert "\n\n#+begin_nav\n")
    (insert-series)
    (insert-series-prev)
    (insert-series-next)
    (insert "\n\n#+end_nav\n")))

(beginning-of-buffer)
(insert-nav)
(insert-title)

(let ((outfile (org-export-output-file-name ".html"))
      (org-html-footnotes-section "<!-- %s --><!-- %s -->"))
  (org-export-to-file 'tufte-html outfile nil nil nil t))