summaryrefslogtreecommitdiff
path: root/haunt/jakob/reader
diff options
context:
space:
mode:
Diffstat (limited to 'haunt/jakob/reader')
-rw-r--r--haunt/jakob/reader/org-mode-prime.scm36
-rw-r--r--haunt/jakob/reader/org-mode.scm12
2 files changed, 47 insertions, 1 deletions
diff --git a/haunt/jakob/reader/org-mode-prime.scm b/haunt/jakob/reader/org-mode-prime.scm
new file mode 100644
index 0000000..118f1a6
--- /dev/null
+++ b/haunt/jakob/reader/org-mode-prime.scm
@@ -0,0 +1,36 @@
+;;; Copyright © 2019 - 2024 Jakob L. Kreuze <zerodaysfordays@sdf.org>
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;;
+;;; Wrapper around the `org-mode-reader' to apply rewrite rules specific to my
+;;; website.
+;;;
+;;; Code:
+
+(define-module (jakob reader org-mode-prime)
+ #:use-module (haunt reader)
+ #:use-module (jakob reader org-mode)
+ #:use-module (jakob utils sxml)
+ #:use-module (srfi srfi-11)
+ #:export (org-mode-reader-prime))
+
+(define org-mode-reader-prime
+ (make-reader (reader-matcher org-mode-reader)
+ (lambda args
+ (let-values (((metadata sxml) (apply (reader-proc org-mode-reader) args)))
+ (values metadata
+ (rewrite-absolute-urls-as-relative sxml))))))
diff --git a/haunt/jakob/reader/org-mode.scm b/haunt/jakob/reader/org-mode.scm
index 7f064f1..b55dbf3 100644
--- a/haunt/jakob/reader/org-mode.scm
+++ b/haunt/jakob/reader/org-mode.scm
@@ -49,6 +49,10 @@
(or (getenv "HAUNT_ORG_READER_CACHE_DIR")
"./.org-mode-reader-cache/"))))
+;; File name of Elisp script to execute before anything else
+(define %additional-emacs-preamble
+ (make-parameter (getenv "HAUNT_ORG_READER_EMACS_PREAMBLE")))
+
;; Additional Org-mode keywords to include in the extracted metadata.
(define %additional-keys
(make-parameter '("CROSSPOST" "SCRIPTS" "META-TAGS")))
@@ -62,7 +66,13 @@
If `%use-emacsclient' is truthy, evaluate FORM in the current running Emacs
daemon. Assumes that FORM does not write to `standard-output'."
- (let* (;; We need to explicitly request that Emacs write the result if using
+ (let* (;; If `HAUNT_ORG_READER_PREAMBLE' is specified, load that.
+ (form (if (%additional-emacs-preamble)
+ `(progn
+ (load-file ,(%additional-emacs-preamble))
+ ,form)
+ form))
+ ;; We need to explicitly request that Emacs write the result if using
;; Emacs batch mode (which is how we evaluate forms without
;; `emacsclient'.)
(form (if (not (%use-emacsclient))