From 6f13402c0794a520b557c471055118026bf419fa Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Fri, 29 May 2020 16:11:39 +0200 Subject: add Ebook --- Makefile.scm | 20 ++++++++++++- templates/book.epub | 71 +++++++++++++++++++++++++++++++++++++++++++++++ templates/ebook/book.epub | 66 ------------------------------------------- 3 files changed, 90 insertions(+), 67 deletions(-) create mode 100644 templates/book.epub delete mode 100644 templates/ebook/book.epub diff --git a/Makefile.scm b/Makefile.scm index b593a3c..cc36c8b 100644 --- a/Makefile.scm +++ b/Makefile.scm @@ -50,7 +50,6 @@ `("./utils/yaml2json.py" ,file) "Error parsing Metadata file"))) -;TODO (define (pandoc-web-simple lang output input) (let ((outpath (make-path output "WebSimple")) (files (directory-sources lang input)) @@ -119,6 +118,24 @@ `("--metadata-file" ,metafile)) "Error in book creation"))) +(define (pandoc-epub lang output input) + (let ((outpath (make-path output "Epub")) + (files (directory-sources lang input)) + (metafile (directory-meta lang input))) + (create-directory* outpath) + (process->string-or-fail + (append + `("pandoc" + "-o" ,(make-path outpath (string-append lang ".epub")) + "--standalone" + "--data-dir=." + ,(string-append "--resource-path=" input) + "--css=./templates/ebook/epub.css" + "--template=book.epub" + "--lua-filter=appendixes.lua") + files + `("--metadata-file" ,metafile)) + "Error in book creation"))) ;; RUN THIS LIKE: ;; chibi-scheme Makefile.scm src/BOOK_FOLDER ;; @@ -133,6 +150,7 @@ (pandoc-web "es" output input) (pandoc-web-simple "es" output input) (pandoc-book "es" output input) +(pandoc-epub "es" output input) ;(display (process->string-or-fail '("./utils/yaml2json.py" "src/Programming_in_Python/es/Metadata.yaml") "")) ;(display (cdr (assoc 'title (read-meta "src/Programming_in_Python/es/Metadata.yaml")))) diff --git a/templates/book.epub b/templates/book.epub new file mode 100644 index 0000000..ae658fa --- /dev/null +++ b/templates/book.epub @@ -0,0 +1,71 @@ + + + + + + + $pagetitle$ +$if(highlighting-css)$ + +$endif$ +$for(css)$ + +$endfor$ +$for(header-includes)$ + $header-includes$ +$endfor$ + + +$if(titlepage)$ +
+$for(title)$ +$if(title.type)$ +

$title.text$

+$else$ +

$title$

+$endif$ +$endfor$ +$if(subtitle)$ +

$subtitle$

+$endif$ +$for(author)$ +

$author$

+$endfor$ +$for(creator)$ +

$creator.text$

+$endfor$ +$if(publisher)$ +

$publisher$

+$endif$ +$if(date)$ +

$date$

+$endif$ +$if(rights)$ +
$rights$
+$endif$ + +
+$if(acknowledgement)$ +
+$acknowledgement$ +
+$endif$ +$else$ +$for(include-before)$ +$include-before$ +$endfor$ +$if(toc)$ +
+$table-of-contents$ +
+$endif$ +$body$ +$for(include-after)$ +$include-after$ +$endfor$ +$endif$ + + + diff --git a/templates/ebook/book.epub b/templates/ebook/book.epub deleted file mode 100644 index 336b608..0000000 --- a/templates/ebook/book.epub +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - $pagetitle$ -$if(highlighting-css)$ - -$endif$ -$for(css)$ - -$endfor$ -$for(header-includes)$ - $header-includes$ -$endfor$ - - -$if(titlepage)$ -
-$for(title)$ -$if(title.type)$ -

$title.text$

-$else$ -

$title$

-$endif$ -$endfor$ -$if(subtitle)$ -

$subtitle$

-$endif$ -$for(author)$ -

$author$

-$endfor$ -$for(creator)$ -

$creator.text$

-$endfor$ -$if(publisher)$ -

$publisher$

-$endif$ -$if(date)$ -

$date$

-$endif$ -$if(rights)$ -
$rights$
-$endif$ - -
-$if(acknowledgement)$ -
-$acknowledgement$ -
-$endif$ -$else$ -$for(include-before)$ -$include-before$ -$endfor$ -$body$ -$for(include-after)$ -$include-after$ -$endfor$ -$endif$ - - - -- cgit v1.2.3