diff options
author | Spencer Williams <spnw@plexwave.org> | 2025-07-11 13:52:01 -0400 |
---|---|---|
committer | Spencer Williams <spnw@plexwave.org> | 2025-07-11 14:16:33 -0400 |
commit | 5c55ec7fcb338306188dac3454782a190205152e (patch) | |
tree | cececa55668ca746c19820a1cc76b6a2164edbc0 | |
parent | 3e6118ec43ce7b875bfa9321d6874a59f501e795 (diff) |
Add raw-title template var
-rw-r--r-- | CHANGELOG.org | 6 | ||||
-rw-r--r-- | lisp/seam-export.el | 12 | ||||
-rw-r--r-- | lisp/seam-test.el | 4 |
3 files changed, 18 insertions, 4 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org index 6526921..109467d 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -46,6 +46,12 @@ - Notes are no longer re-exported unnecessarily whenever a linked note is changed. +- In HTML templates, ={{title}}= now produces output with formatting + stripped out, so that it is more suitable for use in =<title>= tags. + To get a raw HTML-formatted title for =<h1>= tags and the like, you + should use the new ={{{raw-title}}}=. As mentioned above, triple + brackets are the Mustache syntax for interpolating raw HTML. + - When invoking =seam-delete-note=, the note's title is now mentioned. This is to reduce the risk of deleting the wrong note by mistake. diff --git a/lisp/seam-export.el b/lisp/seam-export.el index 8be9404..6f75a21 100644 --- a/lisp/seam-export.el +++ b/lisp/seam-export.el @@ -113,7 +113,7 @@ See `seam-export-alist' for more information about specifying templates." <body> <main> <header> -<h1>{{title}}</h1> +<h1>{{{raw-title}}}</h1> <p class=\"modified\">Last modified: <time datetime=\"{{modified-dt}}\">{{modified}}</time></p> </header> {{{contents}}} @@ -137,7 +137,12 @@ interpolate it as-is. `title' - The note's title (HTML-escaped). + The note's title, in a plain text format suitable for a + <title> tag. + + `raw-title' + + The note's title, in an HTML format suitable for an <h1> tag. `backlinks' @@ -272,6 +277,9 @@ notes)." `(("title" . ,(seam-export--smartquotize-string (seam-get-title-from-file note-file))) + ("raw-title" . + ,(seam-export--escape-string + (seam-get-title-from-file note-file))) ("modified" . ,(format-time-string seam-export-time-format diff --git a/lisp/seam-test.el b/lisp/seam-test.el index a546319..47d4fbb 100644 --- a/lisp/seam-test.el +++ b/lisp/seam-test.el @@ -509,8 +509,8 @@ it." (ert-deftest seam-test-escape-title () (should (equal - "“quotes” & <symbols>\n" - (seam-test-with-notes ((seam-export-template-string "{{{title}}}")) + "“quotes” & <symbols>\n“quotes” & <symbols>\n" + (seam-test-with-notes ((seam-export-template-string "{{title}}\n{{{raw-title}}}")) ((note "\"quotes\" & <symbols>" "public")) (seam-export--file-string "html/quotes-symbols.html"))))) |