Skip to content

Commit edaf1fe

Browse files
use pymdownx.highlight with "linenums_style: table"
1 parent a67db28 commit edaf1fe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tools/run-in-container/genpdf.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ function copy_resources() {
1212
cp -r ${DATA_DIR}/docs/stylesheets ${TARGET_DIR}/docs/stylesheets
1313
}
1414

15+
# Materials for MkDocs 5.5.14 uses CSS that leads to wkhtmltopdf 0.12.6 printing all line numbers before the code with
16+
# - "codehilite" plugin and "linenums: true"
17+
# - "pymdownx.highlight" plugin and "linenums_style: table" (default)
18+
# The workaround is to use "pymdownx.highlight" with "linenums_style: pymdownx-inline" and some CSS fixes
19+
# This is acceptable since the PDF is the secondary format and "pymdownx.highlight" is the newer plugin
20+
# with some nice features for the HTML version.
21+
function fix_mkdocs_yml() {
22+
mv ${TARGET_DIR}/mkdocs.yml ${TARGET_DIR}/mkdocs.ori.yml
23+
sed -e 's/linenums_style: table/linenums_style: pymdownx-inline/g' ${TARGET_DIR}/mkdocs.ori.yml > ${TARGET_DIR}/mkdocs.yml
24+
}
25+
1526
function create_cover() {
1627
sed -e "s/#VERSION#/$(get_version)/g" ${DATA_DIR}/docs/cover-template.html \
1728
| sed -e "s/#YEAR#/$(date +'%Y')/g" > ${TARGET_DIR}/docs/cover.html
@@ -85,6 +96,7 @@ TARGET_DIR=${DATA_DIR}/pdf
8596

8697
create_target_dir
8798
copy_resources
99+
fix_mkdocs_yml
88100
create_cover
89101
write_file "index.md"
90102
write_file "1-introduction/introduction.md"

0 commit comments

Comments
 (0)