From efe8e9cfb4b6662098c7824096c89c7139dce7c6 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 6 Oct 2023 13:26:52 +0100 Subject: [PATCH 1/7] pdf: better build args --- .github/workflows/pages.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 9cb0402..6f62b65 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -73,6 +73,9 @@ jobs: working_directory: _build/latex root_file: book.tex args: -pdf -dvi- -ps- -file-line-error -f -interaction=nonstopmode + latexmk_use_xelatex: true + env: + XINDYOPTS: -L english -C utf8 -M sphinx.xdy continue-on-error: true - name: prepare _site pages run: | From 8c585d5b171e0daea8cbd141bf39bf2e56deb48c Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 6 Oct 2023 21:57:54 +0100 Subject: [PATCH 2/7] pdf: warn on latex errors --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 6f62b65..ad02c37 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -57,7 +57,7 @@ jobs: sudo apt install -qq ghostscript fonts-freefont-otf # https://stackoverflow.com/a/69012150 sed -ri 's#^(\s*baseurl:).*#\1 ${{ steps.pages.outputs.base_url }}/'$SITE_PREFIX'#g' _config.yml jupyter-book build --builder dirhtml --warningiserror --nitpick --keep-going . - jupyter-book build --builder latex . + jupyter-book build --builder latex --warningiserror --nitpick --keep-going . # insert PDF cover cd _build/latex curl -fsSLO https://static.premai.io/book/cover.pdf From d59de22b5c216cdb7ebb65266f963163b7a8018c Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 7 Oct 2023 00:22:12 +0100 Subject: [PATCH 3/7] fix citations in captions --- _config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/_config.yml b/_config.yml index 57a8ded..ae13bf9 100644 --- a/_config.yml +++ b/_config.yml @@ -132,6 +132,11 @@ sphinx: html_last_updated_fmt: '%d %b %Y' jblatex_show_tocs: false bibtex_reference_style: label + latex_elements: + # fix citations in figure captions (https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/276) + preamble: | + \usepackage{etoolbox} + \AtBeginEnvironment{figure}{\pretocmd{\hyperlink}{\protect}{}{}} bibtex_bibfiles: [references.bib] # citations latex: # for PDF builds latex_documents: From fdf3b565d2208ad2f7b15bffc5f1cd34f62c2101 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 7 Oct 2023 00:29:48 +0100 Subject: [PATCH 4/7] pdf: native config --- .github/workflows/pages.yml | 2 -- _config.yml | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index ad02c37..8f451a1 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -62,10 +62,8 @@ jobs: cd _build/latex curl -fsSLO https://static.premai.io/book/cover.pdf sed -i -r \ - -e 's/(\\documentclass.*)letterpaper(.*)/\1a4paper\2/' \ -e 's/(\\usepackage\{geometry\})/\1\n\\usepackage\{pdfpages\}/' \ -e 's/\\sphinxmaketitle/\\includepdf\[pages=-\]\{cover.pdf\}/' \ - -e 's/\\sphinxtableofcontents//' \ book.tex env: {PYTHONPATH: .} - uses: xu-cheng/latex-action@v3 diff --git a/_config.yml b/_config.yml index ae13bf9..10bf1e9 100644 --- a/_config.yml +++ b/_config.yml @@ -133,6 +133,8 @@ sphinx: jblatex_show_tocs: false bibtex_reference_style: label latex_elements: + papersize: a4paper + tableofcontents: '' # fix citations in figure captions (https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/276) preamble: | \usepackage{etoolbox} From 612a5c26df9bf5c444ba241f1a4f72fbe1eed1f4 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 7 Oct 2023 00:34:40 +0100 Subject: [PATCH 5/7] pdf/cover: native config --- .github/workflows/pages.yml | 7 +------ _config.yml | 3 +++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 8f451a1..0383553 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -59,12 +59,7 @@ jobs: jupyter-book build --builder dirhtml --warningiserror --nitpick --keep-going . jupyter-book build --builder latex --warningiserror --nitpick --keep-going . # insert PDF cover - cd _build/latex - curl -fsSLO https://static.premai.io/book/cover.pdf - sed -i -r \ - -e 's/(\\usepackage\{geometry\})/\1\n\\usepackage\{pdfpages\}/' \ - -e 's/\\sphinxmaketitle/\\includepdf\[pages=-\]\{cover.pdf\}/' \ - book.tex + curl -fsSL https://static.premai.io/book/cover.pdf > _build/latex/cover.pdf env: {PYTHONPATH: .} - uses: xu-cheng/latex-action@v3 with: diff --git a/_config.yml b/_config.yml index 10bf1e9..2358671 100644 --- a/_config.yml +++ b/_config.yml @@ -134,6 +134,9 @@ sphinx: bibtex_reference_style: label latex_elements: papersize: a4paper + # requires https://static.premai.io/book/cover.pdf + extrapackages: \usepackage{pdfpages} + maketitle: \includepdf[pages=-]{cover.pdf} tableofcontents: '' # fix citations in figure captions (https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/276) preamble: | From 9cc7ef164f4d2a3eaa4a3aa95c085cd55d3ffdd5 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 7 Oct 2023 20:53:09 +0100 Subject: [PATCH 6/7] pdf: drop unicode emoji --- .github/workflows/pages.yml | 7 +++++++ _config.yml | 1 - index.md | 6 ++---- requirements.txt | 1 - 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 0383553..39bfb4a 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -58,6 +58,13 @@ jobs: sed -ri 's#^(\s*baseurl:).*#\1 ${{ steps.pages.outputs.base_url }}/'$SITE_PREFIX'#g' _config.yml jupyter-book build --builder dirhtml --warningiserror --nitpick --keep-going . jupyter-book build --builder latex --warningiserror --nitpick --keep-going . + # fix undefined in FreeFont + sed -ri \ + -e 's/[🆕🌈🎉💪💬💻📝📥🔠🔌🛠␂↔️⚙️]//g' \ + -e 's/🔴/☒/g' \ + -e 's/🟡/☐/g' \ + -e 's/🟢/☑/g' \ + _build/latex/book.tex # insert PDF cover curl -fsSL https://static.premai.io/book/cover.pdf > _build/latex/cover.pdf env: {PYTHONPATH: .} diff --git a/_config.yml b/_config.yml index 2358671..eef358a 100644 --- a/_config.yml +++ b/_config.yml @@ -80,7 +80,6 @@ parse: - tasklist sphinx: extra_extensions: - - sphinxemoji.sphinxemoji - sphinx_last_updated_by_git - sphinx_subfigure # custom (local *.py files) diff --git a/index.md b/index.md index efcca19..1f76f0b 100644 --- a/index.md +++ b/index.md @@ -84,11 +84,9 @@ Spot something outdated or missing? Want to start a discussion? We welcome any o ### Formatting -````{note} -```{eval-rst} -Don't worry about making it perfect, it's fine to open a (`draft `_) PR and `allow edits from maintainers `_ to fix it |:heart:| +```{note} +Don't worry about making it perfect, it's fine to open a ([draft](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests#draft-pull-requests)) PR and [allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) to fix it ♥ ``` -```` - [Quickstart](https://jupyterbook.org/en/stable/reference/cheatsheet.html) - [Full reference](https://jupyterbook.org/en/stable/content/myst.html) diff --git a/requirements.txt b/requirements.txt index d5a91b2..7a66122 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ jupyter-book -sphinxemoji sphinx-last-updated-by-git # TODO: remove after https://github.com/executablebooks/jupyter-book/pull/2048 docutils!=0.18.*,!=0.19.*,!=0.20.0 From 43838f770aa7ae7bc555140039f5e1bc7ee68621 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 7 Oct 2023 21:13:34 +0100 Subject: [PATCH 7/7] pdf: fix contrib.rocks --- .github/workflows/pages.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 39bfb4a..14822fa 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -58,15 +58,20 @@ jobs: sed -ri 's#^(\s*baseurl:).*#\1 ${{ steps.pages.outputs.base_url }}/'$SITE_PREFIX'#g' _config.yml jupyter-book build --builder dirhtml --warningiserror --nitpick --keep-going . jupyter-book build --builder latex --warningiserror --nitpick --keep-going . + cd _build/latex + # fix contrib.rocks + mv state-of-open-source-ai contrib-rocks.svg + convert contrib-rocks.svg contrib-rocks.png || : + sed -ri 's/(.*includegraphics\{\{)state-of-open-source-ai(\}\}.*)/\1contrib-rocks.png\2/g' book.tex # fix undefined in FreeFont sed -ri \ -e 's/[🆕🌈🎉💪💬💻📝📥🔠🔌🛠␂↔️⚙️]//g' \ -e 's/🔴/☒/g' \ -e 's/🟡/☐/g' \ -e 's/🟢/☑/g' \ - _build/latex/book.tex + book.tex # insert PDF cover - curl -fsSL https://static.premai.io/book/cover.pdf > _build/latex/cover.pdf + curl -fsSLO https://static.premai.io/book/cover.pdf env: {PYTHONPATH: .} - uses: xu-cheng/latex-action@v3 with: