1
0
mirror of https://github.com/funkypenguin/geek-cookbook/ synced 2025-12-13 01:36:23 +00:00

Experiment with PDF generation

Signed-off-by: David Young <davidy@funkypenguin.co.nz>
This commit is contained in:
David Young
2022-07-08 10:30:09 +12:00
parent 0ed00a624a
commit f20ebc282b
4 changed files with 59 additions and 2 deletions

View File

@@ -1,10 +1,24 @@
ARG FROM_SOURCE=squidfunk/mkdocs-material
FROM ${FROM_SOURCE}
RUN apk add --no-cache py3-pip py3-pillow py3-cffi py3-brotli gcc musl-dev python3-dev pango build-base libffi-dev jpeg-dev libxslt-dev
RUN pip install \
mkdocs-autolinks-plugin \
mkdocs-htmlproofer-plugin \
mkdocs-git-revision-date-localized-plugin \
mkdocs-macros-plugin \
mkdocs-git-committers-plugin-2 \
mkdocs-meta-descriptions-plugin
mkdocs-meta-descriptions-plugin \
mkdocs-with-pdf
# Theoretically this could add support for headless chrome
RUN apk add --no-cache \
chromium \
nss \
freetype \
harfbuzz \
ca-certificates \
ttf-freefont \
nodejs \
yarn

39
mkdocs-pdf-print.yml Normal file
View File

@@ -0,0 +1,39 @@
# Used to trigger a PDF build of the site
INHERIT: mkdocs.yml
plugins:
with-pdf:
author: David Young
copyright: ANY TEXT
cover: false
back_cover: true
cover_title: TITLE TEXT
cover_subtitle: SUBTITLE TEXT
custom_template_path: TEMPLATES PATH
toc_title: TOC TITLE TEXT
heading_shift: false
toc_level: 3
ordered_chapter_level: 2
excludes_children:
- 'release-notes/:upgrading'
- 'release-notes/:changelog'
exclude_pages:
- 'bugs/'
- 'appendix/contribute/'
convert_iframe:
- src: IFRAME SRC
img: POSTER IMAGE URL
text: ALTERNATE TEXT
- src: ...
two_columns_level: 3
render_js: true
headless_chrome_path: headless-chromium
output_path: any-place/document.pdf
enabled_if_env: ENABLE_PDF_EXPORT
debug_html: true
show_anchors: true
verbose: true

View File

@@ -1,3 +1,3 @@
#!/bin/bash
docker build --build-arg FROM_SOURCE=ghcr.io/geek-cookbook/mkdocs-material-insiders . -t funkypenguin/mkdocs-material
docker build --build-arg FROM_SOURCE=ghcr.io/geek-cookbook/mkdocs-material-insiders . -t funkypenguin/mkdocs-material --platform amd64
docker run --rm --name mkdocs-material -v ${PWD}:/docs funkypenguin/mkdocs-material build -f mkdocs-insiders.yml

4
scripts/build-pdf.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
set -e
docker build --build-arg FROM_SOURCE=ghcr.io/geek-cookbook/mkdocs-material-insiders . -t funkypenguin/mkdocs-material --platform amd64
docker run --rm --name mkdocs-material -e ENABLE_PDF_EXPORT=1 -v ${PWD}:/docs funkypenguin/mkdocs-material build -f mkdocs-pdf-print.yml