aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.md4
-rw-r--r--TODO.md2
-rwxr-xr-xbin/compile-book3
-rwxr-xr-xbin/compile-notes3
-rw-r--r--templates/_output.yml112
5 files changed, 121 insertions, 3 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index 119cfa5..d8ca7b1 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -2,9 +2,11 @@
## v0.0.8 - unreleased
-* [x] Towards localization support:
+* [x] Localization support:
* [x] Detect the `lang` YAML parameters and use templates from
`{templates,structure}/{book,notes}/$lang`.
+ * [x] Compile the `_output.yml` from a template, setting the `includes`
+ from the appropriate language-based structure files.
## v0.0.7 - 2024-06-09
diff --git a/TODO.md b/TODO.md
index 1d51bd9..2fb9f84 100644
--- a/TODO.md
+++ b/TODO.md
@@ -16,8 +16,6 @@
## Improvements
* [ ] Localization:
- * [ ] Compile the `_output.yml` from a template, setting the `includes`
- from the appropriate language-based structure files.
* [ ] Setup a PO-file workflow for translating the structure and templates?
* [ ] Formats:
* [ ] Fix the EPUB output:
diff --git a/bin/compile-book b/bin/compile-book
index 5c8447a..e3a8b45 100755
--- a/bin/compile-book
+++ b/bin/compile-book
@@ -18,6 +18,9 @@ if [ -z "$LANG" ]; then
LANG="en"
fi
+# Update _output.yml with language information
+sed -e "s|%%lang%%|$LANG|g" templates/_output.yml > _output.yml
+
# Set structure and templates
STRUCTURE="structure/book/$LANG"
TEMPLATES="templates/book/$LANG"
diff --git a/bin/compile-notes b/bin/compile-notes
index c56c56b..460f8f2 100755
--- a/bin/compile-notes
+++ b/bin/compile-notes
@@ -22,6 +22,9 @@ fi
STRUCTURE="structure/notes/$LANG"
TEMPLATES="templates/notes/$LANG"
+# Update _output.yml with language information
+sed -e "s|%%lang%%|$LANG|g" templates/_output.yml > _output.yml
+
# Remove any dangling output files
rm -f $OUTPUT.md
diff --git a/templates/_output.yml b/templates/_output.yml
new file mode 100644
index 0000000..e641047
--- /dev/null
+++ b/templates/_output.yml
@@ -0,0 +1,112 @@
+# Bookdown output configuration
+# See https://bookdown.org/yihui/bookdown/output-formats.html
+
+# EPUB
+# See https://rdrr.io/cran/bookdown/man/epub_book.html
+epub_book:
+ toc: true
+ toc_depth: 3
+ chapter_level: 2
+ cover_image: images/cover.png
+ epub_version: epub3
+
+ # Make sure to disable Pandoc's example_lists extension
+ # It conflicts with bibliographical citations
+ # Check ChangeLog entry from 2024-03-24 on the `ensaios` repository
+ md_extensions: -example_lists
+
+# Tufte HTML
+tufte:tufte_html:
+ toc: true
+ toc_depth: 3
+ chapter_level: 2
+ cover_image: images/cover.png
+
+ # Make sure to disable Pandoc's example_lists extension
+ # It conflicts with bibliographical citations
+ # Check ChangeLog entry from 2024-03-24 on the `ensaios` repository
+ md_extensions: -example_lists
+
+# Gitbook
+# See https://rdrr.io/cran/bookdown/man/gitbook.html
+bookdown::gitbook:
+ config:
+ toc:
+ collapse: section
+ toolbar:
+ search:
+ engine: fuse
+ sharing: no
+ fontsettings:
+ theme: night
+ family: sans
+ size: 2
+ #split_by: chapter+number
+ split_by: chapter
+
+ # Make sure to disable Pandoc's example_lists extension
+ # It conflicts with bibliographical citations
+ # Check ChangeLog entry from 2024-03-24 on the `ensaios` repository
+ md_extensions: -example_lists
+
+# Tufte Book 2
+# See https://rdrr.io/cran/bookdown/man/pdf_book.html
+bookdown::tufte_book2:
+ # Using a custom Tufte Handout template due do the following issues:
+ #
+ # * Unable to set any other language (! Argument of \str_uppercase:n has an extra }.) #278
+ # https://github.com/Wandmalfarbe/pandoc-latex-template/issues/278
+ #
+ # * for newest pandoc, only use babel, never polyglossia #20
+ # https://github.com/JensErat/pandoc-scrlttr2/issues/20
+ #
+ # * Suggestion for improvement: selectable babel for non-pdflatex #794
+ # https://github.com/rstudio/bookdown/issues/794
+ #
+ # The original tufe-handout.tex template can be found at
+ # https://github.com/rstudio/tufte/blob/main/inst/rmarkdown/templates/tufte_handout/resources/tufte-handout.tex
+ #
+ # Using the patch from
+ # https://github.com/idiv-biodiversity/pandoc-cheat-sheet/pull/2
+ #
+ # Check also
+ # https://bookdown.org/yihui/rmarkdown/pdf-document.html#custom-templates-1
+ #
+ # We may move back to the vanilla template once this issue is fixed upstream.
+ template: vendor/bookup/templates/tufte-handout.tex
+
+ includes:
+ in_header: vendor/bookup/structure/book/%%lang%%/00-header.tex
+ before_body: vendor/bookup/structure/book/%%lang%%/00-preamble.tex
+ after_body: vendor/bookup/structure/book/%%lang%%/99-end.tex
+ toc: true
+ toc_depth: 3
+ #toc_appendix: true
+ #toc_bib: true
+ number_sections: true
+ keep_tex: true
+ latex_engine: "xelatex"
+
+ # The natbib package does not support translating the author separator, only "and" is supported.
+ # So better to stick with pandoc-citeproc.
+ #
+ # Also,
+ #
+ # > Even if you choose natbib or biblatex for PDF output, all other output
+ # > formats will be using pandoc-citeproc. If you use matching styles (e.g.,
+ # > biblio-style: apa for biblatex along with csl: apa.csl for
+ # > pandoc-citeproc), output to PDF and to non-PDF formats will be very
+ # > similar, though not necessarily identical.
+ # >
+ # > -- https://bookdown.org/yihui/bookdown/citations.html
+ #citation_package: "natbib"
+
+ # Memory issues
+ # https://community.rstudio.com/t/bookdown-memory-issues-upon-compilation/16829
+ #pandoc_args: [ "+RTS", "-K1024m", "-RTS" ]
+ #pandoc_args: [ "--variable=geometry:paperwidth=6in,paperheight=9in" ]
+
+ # Make sure to disable Pandoc's example_lists extension
+ # It conflicts with bibliographical citations
+ # Check ChangeLog entry from 2024-03-24 on the `ensaios` repository
+ md_extensions: -example_lists