Skip to content

Commit 38f5b0c

Browse files
authored
Merge pull request #877 from kyselejsyrecek/svg-workaround
Work around broken export of SVGs not compliant with the 1.1 standard
2 parents 3fc1f0b + 7cc26cc commit 38f5b0c

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

Dockerfile

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
FROM lrx0014/gitbook:3.2.3
1+
FROM kyselejsyrecek/gitbook:3.2.3
22
COPY ./ /srv/gitbook/
33
EXPOSE 4000
4+
WORKDIR /srv/gitbook
5+
CMD ["sh", "-c", "/usr/local/bin/gitbook serve"]
46

5-
# Update sources.list for Debian Jessie.
6-
RUN rm /etc/apt/sources.list
7-
RUN echo "deb http://archive.debian.org/debian-security jessie/updates main" >> /etc/apt/sources.list.d/jessie.list
8-
RUN echo "deb http://archive.debian.org/debian jessie main" >> /etc/apt/sources.list.d/jessie.list
9-
RUN apt update
10-
RUN apt install -y --force-yes calibre bzip2
11-
RUN npm install svgexport@0.3.0 -g
12-
13-
# Install CommandBox (https://commandbox.ortusbooks.com/setup/installation).
14-
# Requires OpenJDK 11 but only version 7 is available from Debian Jessie repositories.
15-
# Run that on a more up-to-date system.
16-
#RUN apt install -y libappindicator3-dev openjdk-11-jdk
17-
#RUN curl -fsSl https://downloads.ortussolutions.com/debs/gpg | gpg --dearmor | tee /usr/share/keyrings/ortussolutions.gpg > /dev/null
18-
#RUN echo "deb [signed-by=/usr/share/keyrings/ortussolutions.gpg] https://downloads.ortussolutions.com/debs/noarch /" | tee /etc/apt/sources.list.d/commandbox.list
19-
#RUN apt-get update && apt-get install -y apt-transport-https commandbox
20-
21-
# Install gitbook-exporter into the CommandBox.
22-
#RUN box install gitbook-exporter
23-
24-
# Run CommandBox shell with gitbook command available. (https://www.forgebox.io/view/gitbook-exporter)
257
# Examples:
268
#RUN gitbook pdf
279
#RUN gitbook epub

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ image: ## docker image build ...
2222

2323
.PHONY: sh
2424
sh: ## run interactive shell inside an already running docker container ...
25-
docker exec -it linux-insides-book sh
25+
docker exec -it linux-insides-book bash
2626

2727
.PHONY: rm
2828
rm: ## remove the docker container ...
@@ -35,15 +35,26 @@ logs: ## gather logs from the docker container ...
3535

3636
.PHONY: export
3737
export: ## run e-book generation inside an already running docker container ...
38-
docker exec linux-insides-book /bin/bash -c " \
38+
docker exec linux-insides-book /bin/bash -c ' \
39+
find . -type f -name '*.svg' -a ! \( -path "./.github/*" -o -path "./_book/*" \) -print0 | while IFS= read -r -d "" svg_file; do \
40+
output_file="$${svg_file%.svg}.png"; \
41+
chapter_dir=$$(dirname $$(dirname "$$svg_file")); \
42+
svg_relative_path="$${svg_file#$$chapter_dir/}"; \
43+
output_relative_path="$${output_file#$$chapter_dir/}"; \
44+
inkscape --export-png="$$output_file" \
45+
--export-area-page \
46+
--export-dpi=150 \
47+
"$$svg_file"; \
48+
find "$$chapter_dir" -maxdepth 1 -type f -name "*.md" -print0 | xargs -0 sed -i "s|\\([/ \\t\\(]\\)$${svg_relative_path}|\\1$${output_relative_path}|g"; \
49+
done; \
3950
gitbook epub; \
4051
gitbook mobi; \
4152
gitbook pdf; \
4253
mv book.pdf book-A4.pdf; \
4354
mv book-A5.json book.json; \
4455
gitbook pdf; \
4556
mv book.pdf book-A5.pdf; \
46-
mv book-A4.pdf book.pdf"
57+
mv book-A4.pdf book.pdf'
4758

4859
.PHONY: cp
4960
cp: ## copy all exported e-book formats to current working directory ...

0 commit comments

Comments
 (0)