diff options
Diffstat (limited to 'repo/www')
| -rw-r--r-- | repo/www/TODO | 14 | ||||
| -rw-r--r-- | repo/www/preprocess-org.el | 25 |
2 files changed, 25 insertions, 14 deletions
diff --git a/repo/www/TODO b/repo/www/TODO index 7eac4fe..1799529 100644 --- a/repo/www/TODO +++ b/repo/www/TODO @@ -1,15 +1,13 @@ -- preprocess Org files - Org's HTML backend adds a lot of stuff I don't like (intermediate - divs, unstable section IDs); I'll use the markdown backend, then - feed that to pandoc - - change description of custom +LINKs - - convert properties - - convert tags +- org preprocessing: + - dump properties + - fontify TODO keywords - compute "leak count" on toplevel index - get stylin' - pandoc template - tufte css? at least sidenotes rather than footnotes -- use tags somehow (eg to fill in the "keywords" metadata in pandoc template) +- use tags somehow, eg + - fill in the "keywords" metadata in pandoc template + - index files/sections by tags - add author - add creation & last update dates - link to history diff --git a/repo/www/preprocess-org.el b/repo/www/preprocess-org.el index 4963326..01c5e0c 100644 --- a/repo/www/preprocess-org.el +++ b/repo/www/preprocess-org.el @@ -47,24 +47,37 @@ (insert "#+end_tags\n")))))) (defun pp-org/expand-links () + ;; Expand #+LINK abbreviations, since pandoc does not grok them. + ;; Also, use the abbreviation as default description for links that + ;; lack one. (pcase-dolist (`(,key . ,expansion) org-link-abbrev-alist-local) (goto-char (point-min)) (let ((link-re (rx "[[" (group (literal key) ":" - (group (+ (not "]")))))) - (replacement (if (string-match-p "%s" expansion) + (group (+ (not "]")))) + "]" (? (group "[" + (group (+ (not "]"))) + "]")) + "]")) + (expand-link (if (string-match-p "%s" expansion) (lambda (tag) (format expansion tag)) (lambda (tag) (concat expansion tag))))) (while (re-search-forward link-re nil t) - (let ((full-link (funcall replacement (match-string 2)))) - (replace-match full-link t t nil 1)))))) + (let ((link-beg (match-beginning 0)) + (link-abbrev (match-string 1)) + (link-tag (match-string 2)) + (description (match-string 4))) + (replace-match (funcall expand-link link-tag) t t nil 1) + (unless description + (save-excursion + (goto-char (1+ link-beg)) + (forward-sexp) + (insert (format "[%s]" link-abbrev))))))))) (defun preprocess-org (input) (with-temp-buffer (insert "#+OPTIONS: ^:{} tags:nil\n") (insert-file-contents input) (org-mode) - ;; TODO: dump properties - ;; TODO: fontify TODO keywords (pp-org/list-tags) (pp-org/expand-links) (princ (buffer-string)))) |
