summaryrefslogtreecommitdiff
path: root/repo/www/preprocess-org.el
diff options
context:
space:
mode:
Diffstat (limited to 'repo/www/preprocess-org.el')
-rw-r--r--repo/www/preprocess-org.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/repo/www/preprocess-org.el b/repo/www/preprocess-org.el
index bad9f90..fda4476 100644
--- a/repo/www/preprocess-org.el
+++ b/repo/www/preprocess-org.el
@@ -1,3 +1,5 @@
+;; -*- lexical-binding: t -*-
+
;; How I Convert Org Files To HTML.
;; ================================
;;
@@ -48,5 +50,14 @@
(insert "#+end_tags\n")))))
;; TODO: dump properties
;; TODO: fontify TODO keywords
- ;; TODO: expand #+LINK abbreviations
+ (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)
+ (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)))))
(princ (buffer-string))))