aboutsummaryrefslogtreecommitdiff
path: root/Makefile.bookup
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2024-06-09 11:28:11 +0100
committerSilvio Rhatto <rhatto@riseup.net>2024-06-09 11:28:11 +0100
commit08fe9f739dcf1570ce0321db979a410fe61ebd60 (patch)
tree05b98e7f6036682d86be2f66873a1807c753c8db /Makefile.bookup
parentad5dc9ae41051b5de11904620ea6f973cdf306ad (diff)
downloadbookup-08fe9f739dcf1570ce0321db979a410fe61ebd60.tar.gz
bookup-08fe9f739dcf1570ce0321db979a410fe61ebd60.tar.bz2
Feat: improved compilation procedures
Diffstat (limited to 'Makefile.bookup')
-rw-r--r--Makefile.bookup43
1 files changed, 11 insertions, 32 deletions
diff --git a/Makefile.bookup b/Makefile.bookup
index 3df0384..2701b1b 100644
--- a/Makefile.bookup
+++ b/Makefile.bookup
@@ -27,6 +27,7 @@ WEBSITE ?= $(PROJECT)
PDF_STYLE ?= bookdown::tufte_book2
# HTML style
+#HTML_STYLE ?= bookdown::html_book
HTML_STYLE ?= bookdown::gitbook
#
@@ -72,9 +73,9 @@ archive:
clean:
@true
@rm -f $(OUTPUT).aux $(OUTPUT).log $(OUTPUT).nav $(OUTPUT).out $(OUTPUT).snm $(OUTPUT).tex $(OUTPUT).toc $(OUTPUT).vrb
- @#rm -f index.md index.Rmd
+ @rm -f index.md index.Rmd
@rm -f _main.log _main.tex _main.loe _main.Rmd
- @rm -rf _book _bookdown_files
+ @rm -rf _book _bookdown_files _main_files
#
# Submodules
@@ -98,26 +99,10 @@ metadata:
#
compile_book: metadata
- @rm -f $(OUTPUT).md
- @#cat sections/*.md >> $(OUTPUT).md
- @/bin/bash -c 'cat _bookup.yml >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md'
- @/bin/bash -c 'cat _biblio.yml >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md'
- @/bin/bash -c 'for file in $(BOOKUP)/structure/00*.yml; do cat $$file >> $(OUTPUT).md ; echo "---" >> $(OUTPUT).md; done'
- @/bin/bash -c 'for file in $(BOOKUP)/structure/00*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done'
- @#/bin/bash -c 'for file in content/sections/*/*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md ; cat $(BOOKUP)/templates/references.md >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done'
- @#/bin/bash -c 'for file in content/sections/*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md ; cat $(BOOKUP)/templates/references.md >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done'
- @/bin/bash -c 'find content/sections -type f | grep '\.md$$' | sort | while read file; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md ; cat $(BOOKUP)/templates/references.md >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done'
- @/bin/bash -c 'for file in $(BOOKUP)/structure/99*.md; do cat $$file >> $(OUTPUT).md ; echo "" >> $(OUTPUT).md; done'
- @sed -i -e "s|%%revision%%|$(REVISION)|g" -e "s|%%date%%|$(DATE)|g" $(OUTPUT).md
- @test -e snippets/terminology.sed && sed -i -f snippets/terminology.sed $(OUTPUT).md || true
- @ln -sf $(OUTPUT).md $(OUTPUT).Rmd
+ @$(BOOKUP)/bin/compile-book $(OUTPUT) $(REVISION) $(DATE)
compile_notes: metadata
- @rm -f notes.md
- @/bin/bash -c 'find content/notes -type f | grep '\.md$$' | sort | while read file; do cat $$file >> notes.md; echo "" >> notes.md; done; echo "# Bibliografia" >> notes.md'
- @sed -i -e "s|%%revision%%|$(REVISION)|g" -e "s|%%date%%|$(DATE)|g" notes.md
- @test -e snippets/terminology.sed && sed -i -f snippets/terminology.sed notes.md || true
- @ln -s notes.md notes.Rmd
+ @$(BOOKUP)/bin/compile-notes notes $(REVISION) $(DATE)
compile: compile_book move_book compile_notes move_note
@true
@@ -130,11 +115,7 @@ bookdown_clean:
@rm -f _main.Rmd
bookdown_html:
- @# Needs to backup the index.html to avoid overwriting
- @#mv index.html index.html.old
-
# Cleanup
- @#rm -rf $(OUTPUT)/html $(OUTPUT)/$(OUTPUT).html
@rm -rf $(OUTPUT_FOLDER)
# Fix references
@@ -150,11 +131,12 @@ bookdown_html:
# Restore $(OUTPUT).md after the weird reference fix
@#mv $(OUTPUT).md.base $(OUTPUT).md
+ # Fix the index file name
# See https://stackoverflow.com/questions/58340924/bookdown-generates-index-file-with-a-chapter-title-instead-of-index-html-when
# Fixed using section ID naming in the preamble
- #@cd _book && ln -s "inĂ­cio.html" index.html
- @#mv _book $(OUTPUT)/html
- @#mv index.html.old index.html
+ #@cd _book && ln -s "introduction.html" index.html
+
+ # Move the book to the output folder
@mv _book $(OUTPUT_FOLDER)
# Replace fuse.js from CDN to local
@@ -181,8 +163,6 @@ bookdown_pdf:
@Rscript -e 'bookdown::render_book("$(OUTPUT).md", "$(PDF_STYLE)")'
# Move
- @#mv _main.pdf $(OUTPUT).pdf
- @#mv _book/_main.pdf $(OUTPUT)/$(OUTPUT).pdf
@mv _book/_main.pdf $(OUTPUT_FOLDER)/$(OUTPUT).pdf
# Use sed to convert tufte::margin_note to marginfigure
@@ -228,7 +208,7 @@ move_notes:
# Too many section levels (nesting) to produce a PDF output
#bookdown_notes_pdf:
-# @Rscript -e 'bookdown::render_book("notes.Rmd", "bookdown::tufte_book2")'
+# @Rscript -e 'bookdown::render_book("notes.Rmd", "$(PDF_STYLE)")'
bookdown_notes_html:
# Fix references
@@ -237,8 +217,7 @@ bookdown_notes_html:
@sed -e 's/\\\\citet{\([^}]*\)}/@\1/g' notes.md > notes.new && mv notes.new notes.md
# Build
- @#Rscript -e 'bookdown::render_book("notes.Rmd", "bookdown::html_book")'
- @Rscript -e 'bookdown::render_book("notes.Rmd", "bookdown::gitbook")'
+ @Rscript -e 'bookdown::render_book("notes.Rmd", "$(HTML_STYLE)")'
# Cleanup old notes
@rm -rf notebook