Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to generated PDF document #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/md-to-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ 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
--include-before-body ./.github/workflows/pdf/title.tex
--lua-filter ./.github/workflows/pdf/link-gifs.lua
--file-scope
--table-of-contents
--number-sections
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/pdf/link-gifs.lua
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions .github/workflows/pdf/title.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}