From 73a076b4964dd26d3a76f84927286519df5c26db Mon Sep 17 00:00:00 2001 From: Sam Turner <98767222+stmio@users.noreply.github.com> Date: Sat, 12 Aug 2023 14:52:24 +0100 Subject: [PATCH 1/2] Link to view GIFs in browser --- .github/workflows/md-to-pdf.yml | 1 + .github/workflows/pdf/link-gifs.lua | 20 ++++++++++++++++++++ .github/workflows/pdf/title.tex | 7 +++++++ 3 files changed, 28 insertions(+) create mode 100644 .github/workflows/pdf/link-gifs.lua diff --git a/.github/workflows/md-to-pdf.yml b/.github/workflows/md-to-pdf.yml index 1b00fa2..bbaaec7 100644 --- a/.github/workflows/md-to-pdf.yml +++ b/.github/workflows/md-to-pdf.yml @@ -20,6 +20,7 @@ jobs: -f markdown_github --include-in-header ./.github/workflows/pdf/header.tex --include-before-body ./.github/workflows/pdf/title.tex + --lua-filter ./.github/workflows/pdf/link-gifs.lua --file-scope --table-of-contents --number-sections diff --git a/.github/workflows/pdf/link-gifs.lua b/.github/workflows/pdf/link-gifs.lua new file mode 100644 index 0000000..5c6ddfc --- /dev/null +++ b/.github/workflows/pdf/link-gifs.lua @@ -0,0 +1,20 @@ +function Image(img) + if img.src:match("^.+(%..+)$") == ".gif" then + local link + + if string.find(img.src, "www") then + -- Image source is already a URL + link = "https:" .. img.src + else + -- Image source is a local file + link = "https://aseprite.org/docs/" .. img.src + end + + return pandoc.Link( + pandoc.Image(img.caption, img.src, img.title, img.attr), + link + ) + else + return img + end +end diff --git a/.github/workflows/pdf/title.tex b/.github/workflows/pdf/title.tex index 329de20..3711fbd 100644 --- a/.github/workflows/pdf/title.tex +++ b/.github/workflows/pdf/title.tex @@ -2,3 +2,10 @@ \maketitle \lhead{Aseprite Documentation} \rhead{\today} +\begin{center} + This is the PDF version of the \href{https://aseprite.org/docs/}{online Aseprite documentation}. + The latest version of this document can be downloaded from the \href{https://github.com/aseprite/docs/}{docs GitHub repository}. + + Some images in this document are GIF animations, which can not be played when embedded in a PDF. + GIFs are linked to their online counterpart, so you can click the image to view the animation in your browser. +\end{center} From fe9cfaebd6afc4f06a0e11b4c0958593e9b90e81 Mon Sep 17 00:00:00 2001 From: Sam Turner <98767222+stmio@users.noreply.github.com> Date: Sat, 12 Aug 2023 14:52:50 +0100 Subject: [PATCH 2/2] Move overview section to start of PDF document --- .github/workflows/md-to-pdf.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/md-to-pdf.yml b/.github/workflows/md-to-pdf.yml index bbaaec7..b8108ef 100644 --- a/.github/workflows/md-to-pdf.yml +++ b/.github/workflows/md-to-pdf.yml @@ -10,12 +10,12 @@ jobs: - name: Create file list id: files_list run: | - echo "files=$(printf '\"%s\" ' *.md | sed 's/ \"sidebar\.md\"/ /' && printf '\"%s\" ' extensions/*.md)" > $GITHUB_OUTPUT + echo "files=$(printf '\"%s\" ' *.md | sed 's/ \"sidebar\.md\"/ /' | sed 's/ \"overview\.md\"/ /' && printf '\"%s\" ' extensions/*.md)" > $GITHUB_OUTPUT mkdir output - uses: docker://pandoc/extra:latest-ubuntu with: args: >- - --output=output/aseprite-docs.pdf ${{ steps.files_list.outputs.files }} + --output=output/aseprite-docs.pdf "overview.md" ${{ steps.files_list.outputs.files }} --pdf-engine=lualatex -f markdown_github --include-in-header ./.github/workflows/pdf/header.tex