Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf: fix hyperref #79

Merged
merged 7 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,30 @@ 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 .
# insert PDF cover
jupyter-book build --builder latex --warningiserror --nitpick --keep-going .
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//' \
# 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' \
book.tex
# insert PDF cover
curl -fsSLO https://static.premai.io/book/cover.pdf
env: {PYTHONPATH: .}
- uses: xu-cheng/latex-action@v3
with:
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: |
Expand Down
11 changes: 10 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ parse:
- tasklist
sphinx:
extra_extensions:
- sphinxemoji.sphinxemoji
- sphinx_last_updated_by_git
- sphinx_subfigure
# custom (local *.py files)
Expand Down Expand Up @@ -132,6 +131,16 @@ sphinx:
html_last_updated_fmt: '%d %b %Y'
jblatex_show_tocs: false
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: |
\usepackage{etoolbox}
\AtBeginEnvironment{figure}{\pretocmd{\hyperlink}{\protect}{}{}}
bibtex_bibfiles: [references.bib] # citations
latex: # for PDF builds
latex_documents:
Expand Down
6 changes: 2 additions & 4 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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 |: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)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading