From 3cebea64952e4b498aee591665f2b6ed50da5498 Mon Sep 17 00:00:00 2001 From: Spencer Williams Date: Sat, 15 Mar 2025 10:34:16 -0400 Subject: Initial commit --- seam-export.el | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 seam-export.el (limited to 'seam-export.el') diff --git a/seam-export.el b/seam-export.el new file mode 100644 index 0000000..3293ef0 --- /dev/null +++ b/seam-export.el @@ -0,0 +1,299 @@ +;;; seam-export.el --- Seam HTML exporter -*- lexical-binding: t -*- + +;; Copyright (c) 2025 Spencer Williams + +;; Author: Spencer Williams + +;; SPDX-License-Identifier: GPL-3.0-or-later + +;; This file is not part of GNU Emacs. + +;; 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 . + +;;; Commentary: + +;; Frontend for Seam's HTML exporter. + +;;; Code: + +(require 'cl-lib) +(require 'seam-html) + +(defvar seam-export--types nil) +(defvar seam-export--template nil) +(defvar seam-export--root-path nil) +(defvar seam-export--no-extension nil) +(defvar seam-export--options nil) + +(defgroup seam-export nil + "Options for Seam exporter." + :tag "Seam Export" + :group 'seam) + +(defcustom seam-export-alist nil + "Association list used by Seam to determine how to export notes. + +The car of each element is an HTML directory to which Seam will export a +subset of notes. The cdr is a plist containing any number of these +properties: + + `:types' + + List of note types to export to this directory. Required. + + `:template-file' + + The HTML template file to be used by the exporter. If this is + missing, falls back to :template-string, `seam-export-template-file', + or `seam-export-template-string' in that order. + + `:template-string' + + The HTML template string to be used by the exporter. If this is + missing, falls back to :template-file, `seam-export-template-file', + or `seam-export-template-string' in that order. + + `:root-path' + + The root path used for rendering internal links. Defaults to \"\", + which means all paths are relative. + + `:no-extension' + + Whether to drop the \".html\" file extension in links. Defaults to + nil. + + `:backend-options' + + A plist of extra options passed to the Org HTML backend. This can be + used to override any of the defaults set in + `seam-export-backend-options'." + :group 'seam-export + :type '(alist :key-type string :value-type plist)) + +(defcustom seam-export-template-file nil + "The HTML template file to be used by the exporter. The template format +is documented at `seam-export-default-template-string'. + +See `seam-export-alist' for more information about specifying templates." + :group 'seam-export + :type '(choice file (const nil))) + +(defvar seam-export-default-template-string + " + + + + +{{title}} + + +
+
+

{{title}}

+

Last modified:

+
+{{contents}} +
+

Backlinks

+{{backlinks}} +
+
+ +" + "The default HTML template string if no other template is specified. + +It should be plain HTML5. Several variables are defined which can be +interpolated using the {{variable}} syntax: + +- contents: The full HTML contents of the note, sans the title header. + +- title: The note's title (HTML-escaped). + +- backlinks: A list (
    ) of notes that link to the given note. + +- modified: The human-readable date that the note was last modified. + See `seam-export-time-format'. + +- modified-dt: The machine-readable date that the note was last + modified. See `seam-export-time-format-datetime'.") + +(defcustom seam-export-template-string seam-export-default-template-string + "The HTML template string to be used by the exporter. The template +format is documented at `seam-export-default-template-string'. + +See `seam-export-alist' for more information about specifying templates." + :group 'seam-export + :type '(choice string (const nil))) + +(defcustom seam-export-time-format "%e %B %Y" + "Human-readable format for template time strings. Passed to +`format-time-string'." + :group 'seam-export + :type 'string) + +(defcustom seam-export-time-format-datetime "%Y-%m-%d" + "Machine-readable format for template time strings. Meant to be used in +the datetime attribute of