diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6309a4f60..c94bd4454d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: Build PDF if: github.repository == 'tldr-pages/tldr' && github.ref == 'refs/heads/main' working-directory: ./scripts/pdf - run: bash build-pdf.sh + run: python render.py ../../pages -c solarized-light - name: Deploy if: github.repository == 'tldr-pages/tldr' && github.ref == 'refs/heads/main' diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 712ad4d8be..d6db2654a9 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -33,13 +33,12 @@ function upload_assets { mv -f "${TLDR_LANG_ARCHIVES_DIRECTORY}"/*.zip "$SITE_HOME/assets/" rm -rf "$TLDR_LANG_ARCHIVES_DIRECTORY" cp -f "$TLDRHOME/index.json" "$SITE_HOME/assets/" - cp -f "${TLDRHOME}/scripts/pdf/tldr-book*.pdf" "${SITE_HOME}/assets/" - + cp -f "${TLDRHOME}/scripts/pdf/tldr-pages.pdf" "${SITE_HOME}/assets/tldr-book.pdf" sha256sum \ "${SITE_HOME}/assets/index.json" \ "${SITE_HOME}/assets/"*.zip \ - "${SITE_HOME}/assets/tldr-book*.pdf" \ + "${SITE_HOME}/assets/tldr-book.pdf" \ > "${SITE_HOME}/assets/tldr.sha256sums" cd "$SITE_HOME" diff --git a/scripts/pdf/NotoSans-Regular.ttf b/scripts/pdf/NotoSans-Regular.ttf deleted file mode 100644 index 7552fbe806..0000000000 Binary files a/scripts/pdf/NotoSans-Regular.ttf and /dev/null differ diff --git a/scripts/pdf/README.md b/scripts/pdf/README.md index 088a3d0df8..b93e1b1a10 100644 --- a/scripts/pdf/README.md +++ b/scripts/pdf/README.md @@ -2,6 +2,12 @@ This directory contains the script and related resources to generate a PDF document with all the `tldr` pages. +## Preview + +![cryptsetup in the Basic color-scheme.](https://user-images.githubusercontent.com/29029116/35637791-4e42af80-06db-11e8-8b8e-42ce6c905ff4.jpg) +![cryptsetup in the Solarized Light color-scheme.](https://user-images.githubusercontent.com/29029116/35637798-51e3784a-06db-11e8-9576-6e57ef5c5c20.jpg) +![cryptsetup in the Solarized Dark color-scheme.](https://user-images.githubusercontent.com/29029116/35637801-54449fce-06db-11e8-93f7-d90cdc34044b.jpg) + ## Highlights - No LaTeX dependencies for generating the PDF. @@ -19,20 +25,14 @@ Make sure OS specific dependencies for WeasyPrint are installed by following the Generating the PDF is as simple as running: - python3 render.py [--color ] [--output ] + python3 render.py --color Complete information about the arguments can be viewed by running: python3 render.py --help -Available color schemes: +The color-schemes that can be specified are: -- `basic` -- `solarized-light` -- `solarized-dark` - -## Preview - -![cryptsetup in the Basic color-scheme.](https://user-images.githubusercontent.com/29029116/35637791-4e42af80-06db-11e8-8b8e-42ce6c905ff4.jpg) -![cryptsetup in the Solarized Light color-scheme.](https://user-images.githubusercontent.com/29029116/35637798-51e3784a-06db-11e8-9576-6e57ef5c5c20.jpg) -![cryptsetup in the Solarized Dark color-scheme.](https://user-images.githubusercontent.com/29029116/35637801-54449fce-06db-11e8-93f7-d90cdc34044b.jpg) +* `basic` +* `solarized-light` +* `solarized-dark` diff --git a/scripts/pdf/basic.css b/scripts/pdf/basic.css index cfc0f10d31..52d794209e 100644 --- a/scripts/pdf/basic.css +++ b/scripts/pdf/basic.css @@ -1,8 +1,8 @@ /* SPDX-License-Identifier: MIT */ @font-face { - font-family: "sans-serif"; - src: url("NotoSans-Regular.ttf") format("truetype"); + font-family: "PT Serif"; + src: url("pt-serif-web-regular.ttf") format("truetype"); } p { @@ -14,7 +14,7 @@ code { } h1, h2, h4, ul { - font-family: "sans-serif"; + font-family: "PT Serif"; } .title-main { diff --git a/scripts/pdf/build-pdf.sh b/scripts/pdf/build-pdf.sh deleted file mode 100644 index 09df4d21a7..0000000000 --- a/scripts/pdf/build-pdf.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# SPDX-License-Identifier: MIT - -# This script is executed by GitHub Actions when a PR is merged (i.e. in the `Build PDF` step). -set -ex - -function process_page { - pageDir="$1" - folder=$(basename "${pageDir}") - language="${folder##*.}" - case $folder in - pages.bn | pages.ja | pages.ko | pages.ml | pages.ta | pages.th | pages.zh | pages.zh_TW) - ;; - pages) - python3 render.py "${pageDir}" -c solarized-light - ;; - *) - python3 render.py "${pageDir}" -c basic -o "tldr-book-${language}.pdf" - ;; - esac -} - -function main { - for pageDir in ../../pages*; do - process_page "${pageDir}" - done -} - -################################### -# MAIN -################################### - -main diff --git a/scripts/pdf/pt-serif-web-regular.ttf b/scripts/pdf/pt-serif-web-regular.ttf new file mode 100644 index 0000000000..5310691a99 Binary files /dev/null and b/scripts/pdf/pt-serif-web-regular.ttf differ diff --git a/scripts/pdf/render.py b/scripts/pdf/render.py index bf1a361e8d..a639acfe83 100644 --- a/scripts/pdf/render.py +++ b/scripts/pdf/render.py @@ -17,7 +17,7 @@ from datetime import datetime from weasyprint import HTML -def main(loc, colorscheme, output_filename): +def main(loc, colorscheme): # Checking correctness of path if not os.path.isdir(loc): print("Invalid directory. Please try again!", file=sys.stderr) @@ -31,13 +31,11 @@ def main(loc, colorscheme, output_filename): # A string that stores all pages in HTML format html = ( '' - + "

tldr pages book

" + + "

tldr pages

" + "
Simplified and community-driven man pages
" + "
Generated on " + datetime.now().strftime("%c") - + "


" - + "
" - + "
" + + "" + '

' ) @@ -71,10 +69,10 @@ def main(loc, colorscheme, output_filename): # Writing the PDF to disk print("\nConverting all pages to PDF...") - HTML(string=html).write_pdf(output_filename, stylesheets=csslist) + HTML(string=html).write_pdf("tldr-pages.pdf", stylesheets=csslist) - if os.path.exists(output_filename): - print(f"\nCreated {output_filename} in the current directory!\n") + if os.path.exists("tldr-pages.pdf"): + print("\nCreated tldr-pages.pdf in the current directory!\n") if __name__ == "__main__": @@ -91,12 +89,6 @@ if __name__ == "__main__": default="basic", help="Color scheme of the PDF", ) - parser.add_argument( - "-o", - "--output", - default="tldr-book.pdf", - help="Custom filename for the output PDF (default is 'tldr-pages.pdf')", - ) args = parser.parse_args() - main(args.dir_path, args.color, args.output) + main(args.dir_path, args.color)