diff options
| author | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-10-06 11:00:24 +0200 |
|---|---|---|
| committer | Kévin Le Gouguec <kevin.legouguec@gmail.com> | 2020-10-06 11:00:24 +0200 |
| commit | 9dceda02d10adcabec2504da8e39cefa2e5b0336 (patch) | |
| tree | 51ce0ddd80c24b76fe60c29d51b909b90d0118cb /repo/www/preprocess-org.el | |
| parent | 348ac65f367ec3b0ce4a517a281810e5c82bd135 (diff) | |
| download | memory-leaks-9dceda02d10adcabec2504da8e39cefa2e5b0336.tar.xz | |
Handle link abbreviations
Diffstat (limited to 'repo/www/preprocess-org.el')
| -rw-r--r-- | repo/www/preprocess-org.el | 13 |
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)))) |
