Recently Written · git

cl-yag

Mirror and rewrite of Solène Rapenne's cl-yag SSG of renown

git clone https://github.com/equwal/cl-yag

Log | Files | Refs


commit a8dfa314e9911295a3c52318d4702e4761093e2f
Solene Rapenne <solene@perso.pw>
2019-08-27 09:10:20 +0200

Add support for differents converters

 generator.lisp | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/generator.lisp b/generator.lisp
index ca01c36..eb483aa 100644
--- a/generator.lisp
+++ b/generator.lisp
@@ -129,24 +129,27 @@
 
 ;; generate the html file from the source file
 ;; using the converter associated with the post
-(defun use-converter-to-html(article)
-  (with-converter
-   (let ((output (converter-command converter-object)))
-     (let* ((src-file (format nil "~a~a" (article-id article) (converter-extension converter-object)))
-	   (dst-file (format nil "temp/data/~a.html" (article-id article) ))
-	   (full-src-file (format nil "data/~a" src-file)))
-       ;; skip generating if the destination exists
-       ;; and is more recent than source
-       (unless (and
-		(probe-file dst-file)
-		(>=
-		 (file-write-date dst-file)
-		 (file-write-date full-src-file)))
-	 (ensure-directories-exist "temp/data/")
-	 (template "%IN" src-file)
-	 (template "%OUT" dst-file)
-	 (format t "~a~%" output)
-	 (uiop:run-program output))))))
+(defun use-converter-to-html(filename &optional (converter-name nil))
+  (let* ((converter-object (getf *converters*
+                                 (or converter-name
+			             converter-name
+			             (getf *config* :default-converter))))
+         (output           (converter-command converter-object))
+         (src-file (format nil "~a~a" filename (converter-extension converter-object)))
+         (dst-file (format nil "temp/data/~a.html" filename ))
+         (full-src-file (format nil "data/~a" src-file)))
+      ;; skip generating if the destination exists
+      ;; and is more recent than source
+      (unless (and
+               (probe-file dst-file)
+               (>=
+                (file-write-date dst-file)
+                (file-write-date full-src-file)))
+        (ensure-directories-exist "temp/data/")
+        (template "%IN" src-file)
+        (template "%OUT" dst-file)
+        (format t "~a~%" output)
+        (uiop:run-program output))))
 
 ;; format the date
 (defun date-format(format date)
@@ -307,9 +310,9 @@
 
   ;; produce each article file
   (loop for article in *articles*
-	do
-	;; use the article's converter to get html code of it
-	(use-converter-to-html article)
+     do
+     ;; use the article's converter to get html code of it
+       (use-converter-to-html (article-id article) (article-converter article))
 
 	(generate  (format nil "output/html/~d-~d.html"
 			   (date-format "%Year-%MonthNumber-%DayNumber"