Add make target to convert all SVGs to plain SVG before rendering

Adapt HTML and EPUB targets to run conversion target before rendering
EPUB or HTML output.

Fixes https://codeberg.org/openpgp/notes/issues/166

Signed-off-by: David Runge <dave@sleepmap.de>
This commit is contained in:
David Runge 2023-12-05 11:34:30 +01:00
parent 28dd67d7f7
commit 43b6080fbe
No known key found for this signature in database
GPG key ID: 90D4B9641E092971
5 changed files with 20 additions and 3 deletions

1
.gitignore vendored
View file

@ -3,3 +3,4 @@
.idea
book/build/
book/source/diag_converted

View file

@ -18,7 +18,7 @@ steps:
image: archlinux:latest
commands:
- pacman -Sy --needed --noconfirm archlinux-keyring
- pacman -Syu --needed --noconfirm epubcheck make patch python-myst-parser python-sphinx
- pacman -Syu --needed --noconfirm epubcheck inkscape make patch python-myst-parser python-sphinx
# fix sphinx: https://github.com/sphinx-doc/sphinx/issues/11598
- patch -Np1 -d /usr/lib/python3.11/site-packages/ -i "$(pwd)/book/patches/sphinx-11766.patch"
- make -C book epub-check

View file

@ -19,5 +19,5 @@ steps:
image: archlinux:latest
commands:
- pacman -Sy --needed --noconfirm archlinux-keyring
- pacman -Syu --needed --noconfirm lychee make python-myst-parser python-sphinx
- pacman -Syu --needed --noconfirm inkscape lychee make python-myst-parser python-sphinx
- make -C book html-linkcheck

View file

@ -7,7 +7,7 @@ WORKDIR /book
# fix EPUB rendering: https://github.com/sphinx-doc/sphinx/issues/11598
RUN \
pacman -Sy --needed --noconfirm archlinux-keyring \
&& pacman -Syu --needed --noconfirm epubcheck make patch python-myst-parser python-sphinx \
&& pacman -Syu --needed --noconfirm inkscape make patch python-myst-parser python-sphinx \
&& patch -Np1 -d /usr/lib/python3.11/site-packages/ -i /book/patches/sphinx-11766.patch \
&& make epub html

View file

@ -9,14 +9,27 @@
CODESPELL ?= codespell
EBOOK_VIEWER ?= ebook-viewer
EPUBCHECK ?= epubcheck
INKSCAPE ?= inkscape
SPHINXOPTS ?= -W
SPHINXBUILD ?= sphinx-build
LYCHEE ?= lychee
PRINTF ?= printf
RM ?= rm
WATCHEXEC ?= watchexec
SOURCEDIR = source
BUILDDIR = build
# clean build output and also preprocessed/ converted data
clean-all: clean
@$(RM) -rv $(SOURCEDIR)/diag_converted/
# convert all SVG to plain SVGs without metadata and paths instead of text
convert-svg:
for file in $(SOURCEDIR)/diag/*.svg; do if [[ ! -f $(SOURCEDIR)/diag_converted/$$(basename $$file) ]]; then $(INKSCAPE) --export-text-to-path --export-plain-svg --export-filename=$(SOURCEDIR)/diag_converted/$$(basename $$file) $$file; fi; done
epub: convert-svg
@$(SPHINXBUILD) -M epub "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
epub-check: clean epub
@$(EPUBCHECK) "$(BUILDDIR)/epub/"*.epub
@ -29,6 +42,9 @@ epub-watch:
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
html: convert-svg
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
html-linkcheck: clean html
@$(LYCHEE) "$(BUILDDIR)/html/"*.html