diff options
| -rw-r--r-- | lisp/seam-export.el | 22 | ||||
| -rw-r--r-- | lisp/seam-test.el | 2 | 
2 files changed, 22 insertions, 2 deletions
diff --git a/lisp/seam-export.el b/lisp/seam-export.el index 698d1f4..8be9404 100644 --- a/lisp/seam-export.el +++ b/lisp/seam-export.el @@ -218,6 +218,21 @@ notes)."                      (buffer-string)))           (kill-buffer ,buf))))) +(defmacro seam-export--to-plain-string (&rest body) +  (declare (indent 0)) +  (let ((buf (gensym))) +    `(let ((,buf (generate-new-buffer " *seam-export*"))) +       (unwind-protect +           (progn (with-temp-buffer +                    ,@body +                    ;; This let prevents Org from popping up a window. +                    (let ((org-export-show-temporary-export-buffer nil) +                          (org-ascii-charset 'utf-8)) +                      (org-export-to-buffer 'ascii ,buf nil nil nil t seam-export--options nil))) +                  (with-current-buffer ,buf +                    (buffer-string))) +         (kill-buffer ,buf))))) +  ;;; Some HACK-ery to get fully escaped and smartquote-ized string.  (defun seam-export--escape-string (s)    (string-remove-prefix @@ -227,6 +242,11 @@ notes)."      (seam-export--to-string        (insert s))))) +(defun seam-export--smartquotize-string (s) +  (string-chop-newline +   (seam-export--to-plain-string +     (insert s)))) +  (defun seam-export--generate-backlinks (file)    (seam-export--to-string      (let ((files (cl-sort @@ -250,7 +270,7 @@ notes)."         (mustache-render          seam-export--template          `(("title" . -           ,(seam-export--escape-string +           ,(seam-export--smartquotize-string               (seam-get-title-from-file note-file)))            ("modified" .             ,(format-time-string diff --git a/lisp/seam-test.el b/lisp/seam-test.el index 6177907..a546319 100644 --- a/lisp/seam-test.el +++ b/lisp/seam-test.el @@ -509,7 +509,7 @@ it."  (ert-deftest seam-test-escape-title ()    (should     (equal -    "“quotes” & <symbols>\n" +    "“quotes” & <symbols>\n"      (seam-test-with-notes ((seam-export-template-string "{{{title}}}"))          ((note "\"quotes\" & <symbols>" "public"))        (seam-export--file-string "html/quotes-symbols.html")))))  | 
