aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSpencer Williams <spnw@plexwave.org>2025-03-29 19:09:35 -0400
committerSpencer Williams <spnw@plexwave.org>2025-03-29 19:12:37 -0400
commitf49a747adfea970f73dc96c07240794c60cec696 (patch)
tree46aa68e4ffd9eae2fde7a2c0b239a6a278535c91
parent0be370b732edd3119c0839275642f76a8a4e7b37 (diff)
Add option to export internal links with custom CSS class
-rw-r--r--seam-export.el17
-rw-r--r--seam-html.el3
-rw-r--r--seam-test.el15
3 files changed, 34 insertions, 1 deletions
diff --git a/seam-export.el b/seam-export.el
index 00312e5..6e39bbc 100644
--- a/seam-export.el
+++ b/seam-export.el
@@ -34,6 +34,7 @@
(defvar seam-export--template nil)
(defvar seam-export--root-path nil)
(defvar seam-export--no-extension nil)
+(defvar seam-export--internal-link-class nil)
(defvar seam-export--options nil)
(defgroup seam-export nil
@@ -74,6 +75,11 @@ properties:
Whether to drop the \".html\" file extension in links. Defaults to
nil.
+ `:internal-link-class'
+
+ CSS class name for internal links. Defaults to the value of
+ `seam-export-internal-link-class'.
+
`:backend-options'
A plist of extra options passed to the Org HTML backend. This can be
@@ -165,6 +171,12 @@ the datetime attribute of <time>. Passed to `format-time-string'."
:group 'seam-export
:type 'sexp)
+(defcustom seam-export-internal-link-class nil
+ "CSS class name to use for internal links (i.e., links to other Seam
+notes)."
+ :group 'seam-export
+ :type 'string)
+
(defvar seam-export-backend-options
(list
:html-container "article"
@@ -292,7 +304,10 @@ the datetime attribute of <time>. Passed to `format-time-string'."
(seam-export--template template)
(seam-export--options (org-combine-plists
seam-export-backend-options
- backend-options)))
+ backend-options))
+ (seam-export--internal-link-class
+ (or (plist-get plist :internal-link-class)
+ seam-export-internal-link-class)))
(seam-export--note-to-html file dir))))))))
(defun seam-export-all-notes ()
diff --git a/seam-html.el b/seam-html.el
index b74be0b..018e56f 100644
--- a/seam-html.el
+++ b/seam-html.el
@@ -195,6 +195,9 @@ INFO is a plist holding contextual information. See
link))))
(and (eq link (org-element-map parent 'link #'identity info t))
(org-export-read-attribute :attr_html parent)))
+ ;; Add Seam internal link class if appropriate.
+ (when (and seam-export--internal-link-class (string= "seam" link-type))
+ (list :class seam-export--internal-link-class))
;; Also add attributes from link itself. Currently, those
;; need to be added programmatically before `org-html-link'
;; is invoked, for example, by backends building upon HTML
diff --git a/seam-test.el b/seam-test.el
index 0b7df1c..7d10f94 100644
--- a/seam-test.el
+++ b/seam-test.el
@@ -47,6 +47,7 @@
(seam-title-formatter (lambda (title _type) title))
(seam-export-template-file nil)
(seam-export-template-string seam-export-default-template-string)
+ (seam-export-internal-link-class nil)
(seam-export-alist
`((,(file-name-concat seam-test-directory "html")
:types ("public")
@@ -254,6 +255,20 @@ extension."
(buffer-string)
(re-search-forward "<a href=\"/bar\">"))))))
+(ert-deftest seam-test-link-internal-class ()
+ "Test that setting `seam-export-internal-link-class' correctly renders
+the class."
+ (should
+ (identity
+ (seam-test-with-notes ((seam-export-internal-link-class "internal"))
+ ((foo "foo" "public")
+ (bar "bar" "public"))
+ (seam-test-add-contents foo (seam-test-link-to-buffer bar))
+ (with-temp-buffer
+ (insert-file-contents "html/foo.html")
+ (buffer-string)
+ (re-search-forward "<a href=\"/bar.html\" class=\"internal\">"))))))
+
(ert-deftest seam-test-link-getters ()
(should
(equal