From 46ad94428d316d4443bc97f5ed9dc11891789525 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Fri, 29 May 2020 13:57:12 +0200 Subject: Update makefile to load folders automatically --- Makefile.scm | 160 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 76 insertions(+), 84 deletions(-) (limited to 'Makefile.scm') diff --git a/Makefile.scm b/Makefile.scm index 639cce9..b593a3c 100644 --- a/Makefile.scm +++ b/Makefile.scm @@ -11,11 +11,6 @@ (srfi 95)) (define debug #t) -;(define output-dir "output") -;(define target "GET_FROM_INPUT") -;(define sources (sort (directory-files (make-path target lang)) stringstring-or-fail - (pandoc-call - (directory-sources lang folder) - (directory-meta lang folder)) - "Error in web-page creation")) - +(define (pandoc-web-simple lang output input) + (let ((outpath (make-path output "WebSimple")) + (files (directory-sources lang input)) + (metafile (directory-meta lang input))) + (create-directory* outpath) + (process->string-or-fail + (append + `("pandoc" + "--to=html" + "-o" ,(make-path outpath (string-append lang ".html")) + "--standalone" + "--no-highlight" + "--data-dir=." + ,(string-append "--resource-path=" input) + "--base-header-level=2" ;"--shift-heading-level-by=-1" is the new way + "--template=web-simple.html" + "--lua-filter=toc.lua" + "--lua-filter=anchored-h.lua" + "--lua-filter=appendixes.lua") + files + `("--metadata-file" ,metafile)) + "Error in web-page creation"))) -; TODO -(define (pandoc-web lang out folder) - "Receives a list of files and an optional metadata file: - (pandoc-web '(file1 file2 ...) metafile)" - (define pandoc-call - (case-lambda - (() `("pandoc" - "--to=html" - "-o" ,out - "--standalone" - "--self-contained" - "--base-header-level=2" ;"--shift-heading-level-by=-1" is the new way - "--data-dir=." - ,(string-append "--resource-path=./templates/web/:./templates:" folder) - "--template=web.html" - "--lua-filter=toc.lua" - "--lua-filter=anchored-h.lua" - "--lua-filter=appendixes.lua")) - ((files) - (append (pandoc-call) files)) - ((files metafile) - (append (pandoc-call files) `("--metadata-file" ,metafile))))) - (process->string-or-fail - (pandoc-call - (directory-sources lang folder) - (directory-meta lang folder)) - "Error in web-page creation")) -(define (pandoc-book lang out folder) - "Receives a list of files and an optional metadata file: - (pandoc-web '(file1 file2 ...) metafile)" - (define pandoc-call - (case-lambda - (() `("pandoc" - "-o" ,out - "--standalone" - "--pdf-engine=xelatex" - "--data-dir=." - ,(string-append "--resource-path=" folder) - "--template=book.latex" - "--lua-filter=appendixes.lua")) - ((files) - (append (pandoc-call) files)) - ((files metafile) - (append (pandoc-call files) `("--metadata-file" ,metafile))))) +(define (pandoc-web lang output input) + (let ((outpath (make-path output "Web")) + (files (directory-sources lang input)) + (metafile (directory-meta lang input))) + (create-directory* outpath) + (process->string-or-fail + (append + `("pandoc" + "--to=html" + "-o" ,(make-path outpath (string-append lang ".html")) + "--standalone" + "--self-contained" + "--base-header-level=2" ;"--shift-heading-level-by=-1" is the new way + "--data-dir=." + ,(string-append "--resource-path=./templates/web/:" + "./templates:" + input) + "--template=web.html" + "--lua-filter=toc.lua" + "--lua-filter=anchored-h.lua" + "--lua-filter=appendixes.lua") + files + `("--metadata-file" ,metafile)) + "Error in web-page creation"))) - (process->string-or-fail - (pandoc-call - (directory-sources lang folder) - (directory-meta lang folder)) - "Error in book creation")) +(define (pandoc-book lang output input) + (let ((outpath (make-path output "Book")) + (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 ".pdf")) + "--standalone" + "--pdf-engine=xelatex" + "--data-dir=." + ,(string-append "--resource-path=" input) + "--template=book.latex" + "--lua-filter=appendixes.lua") + files + `("--metadata-file" ,metafile)) + "Error in book creation"))) ;; RUN THIS LIKE: +;; chibi-scheme Makefile.scm src/BOOK_FOLDER +;; +;; It will dump the compiled book to .out/BOOK_FOLDER/FORMAT/LANG.EXT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define args (cdr (command-line))) -(display (pandoc-web "es" "hola.html" (car args))) -;(display (pandoc-book "es" "hola.pdf" (car args))) +(define args (cdr (command-line))) +(define input (car args)) +(define bookname (path-strip-directory (string-trim-right input #\/))) +(define output (make-path "out" bookname)) + + +(pandoc-web "es" output input) +(pandoc-web-simple "es" output input) +(pandoc-book "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")))) -- cgit v1.2.3