summaryrefslogtreecommitdiff
path: root/repo
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-10-06 10:30:42 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-10-06 10:30:42 +0200
commit348ac65f367ec3b0ce4a517a281810e5c82bd135 (patch)
treeb4081bd92498c369938cfee2727eb0b8e1846a87 /repo
parent3e230d40ab1255aec292df17d7b127b681a55710 (diff)
downloadmemory-leaks-348ac65f367ec3b0ce4a517a281810e5c82bd135.tar.xz
Bang on Org export some more
Diffstat (limited to 'repo')
-rw-r--r--repo/www/helpers.py2
-rw-r--r--repo/www/preprocess-org.el48
2 files changed, 41 insertions, 9 deletions
diff --git a/repo/www/helpers.py b/repo/www/helpers.py
index 34f274f..12d9a41 100644
--- a/repo/www/helpers.py
+++ b/repo/www/helpers.py
@@ -74,7 +74,7 @@ class _OrgPreprocessor:
self._source_path = source_path
def __enter__(self):
- self._output = NamedTemporaryFile(mode='w+', suffix='.md')
+ self._output = NamedTemporaryFile(mode='w+', suffix='.org')
try:
run((
'emacs', '-Q', '--batch', '--load', 'preprocess-org.el',
diff --git a/repo/www/preprocess-org.el b/repo/www/preprocess-org.el
index f7be936..bad9f90 100644
--- a/repo/www/preprocess-org.el
+++ b/repo/www/preprocess-org.el
@@ -1,5 +1,41 @@
+;; How I Convert Org Files To HTML.
+;; ================================
+;;
+;; Or: Why We Can't Have Nice Things: Exhibit #42.
+;; -------------------------------------------
+;;
+;; Or: I Got Way Too Much Time On My Hands, Apparently.
+;; ------------------------------------------------
+;;
+;; I see two straightforward ways to export Org files to HTML:
+;;
+;; 1. ox-html.el, Org's HTML backend: even with all the settings and
+;; filters available, there are still a few things that annoy me:
+;; lots of extra <div>s, unstable section IDs…
+;;
+;; Also, I want to squeeze pandoc somewhere in the pipeline, to run
+;; my Lua filters.
+;;
+;; 2. pandoc: does not cover all of Org's features. Org is so crammed
+;; with constructs that don't exist in other markup formats
+;; (agendas, logbooks, spreadsheets, properties…) and so many knobs
+;; can be tweaked on a per-file basis (link abbreviations, tags,
+;; TODO cycles) that Elisp remains the least painful way to process
+;; these files, IMO.
+;;
+;; A less-straightforward, but still reasonably simple way to go would
+;; be to use Org's markdown backend, then run pandoc on the result.
+;; Unfortunately, AFAICT ox-md.el does not implement definition lists,
+;; nor syntax-highlighting in fenced code blocks.
+;;
+;; So here's where I'm at: using Elisp, I'll preprocess Org files to
+;; add a bunch of #+OPTIONS pandoc recognizes, "dumb down" the stuff
+;; pandoc does not recognize, format some other stuff arbitrarily,
+;; *then* I'll run pandoc on the result.
+
(defun preprocess-org (input)
(with-temp-buffer
+ (insert "#+OPTIONS: ^:{} tags:nil\n")
(insert-file-contents input)
(org-mode)
(while (re-search-forward org-heading-regexp nil t)
@@ -10,11 +46,7 @@
(dolist (tag tags)
(insert "- " tag "\n"))
(insert "#+end_tags\n")))))
- (let ((org-export-with-properties t)
- (org-export-with-section-numbers nil)
- (org-export-with-sub-superscripts '{})
- (org-export-with-tags nil)
- (org-export-with-title nil)
- (org-export-with-toc nil))
- (org-md-export-as-markdown))
- (princ (buffer-string))))
+ ;; TODO: dump properties
+ ;; TODO: fontify TODO keywords
+ ;; TODO: expand #+LINK abbreviations
+ (princ (buffer-string))))