summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.scm160
1 files changed, 76 insertions, 84 deletions
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)) string<?))
-;(define metadata (make-path target lang "Metadata.yaml"))
-;(define output (make-path output-dir target))
(define (directory-files-not-hidden dir)
(filter
@@ -56,91 +51,88 @@
"Error parsing Metadata file")))
;TODO
-(define (pandoc-web-simple 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"
- "--no-highlight"
- "--data-dir=."
- ,(string-append "--resource-path=templates/web:" folder)
- "--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)
- (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-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"))))