From 8575a67b43ac8dca0bc216f520eb8bd3b9f2e0f4 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Fri, 29 Oct 2021 18:25:10 +0200 Subject: [PATCH 01/13] Provide target name for pdf --- .github/workflows/build-wiki-pdf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index 9cfe129773..98b70e1d34 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -12,7 +12,7 @@ jobs: - working-directory: util/wiki run: pip3 install -r requirements.txt - working-directory: util/wiki - run: python3 ./generate_wiki_pdf.py --pdf + run: python3 ./generate_wiki_pdf.py --pdf wiki.pdf - working-directory: util/wiki run: ls - name: Set wiki pdf tag in github repo From 668c15c96761a04f0bcfeceabe9208d6669ed487 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Fri, 29 Oct 2021 18:25:28 +0200 Subject: [PATCH 02/13] Run on push --- .github/workflows/build-wiki-pdf.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index 98b70e1d34..492a7c7159 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -1,7 +1,6 @@ name: Vercors wiki pdf workflow # Only run when the wiki is updated -on: - gollum +on: push jobs: make_pdf: runs-on: ubuntu-latest From c4e7c1d2a477ed8dfdcee25cef378592073e2f3f Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Fri, 29 Oct 2021 18:30:31 +0200 Subject: [PATCH 03/13] Install xelatex --- .github/workflows/build-wiki-pdf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index 492a7c7159..efe1d17c06 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -7,7 +7,7 @@ jobs: steps: - uses: technote-space/auto-cancel-redundant-workflow@v1 - uses: actions/checkout@v2 - - run: sudo apt install pandoc + - run: sudo apt install pandoc texlive-xetex - working-directory: util/wiki run: pip3 install -r requirements.txt - working-directory: util/wiki From c499d19387b98836d52dd912e5ff553e15209734 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Fri, 29 Oct 2021 18:36:23 +0200 Subject: [PATCH 04/13] Remove conditional if for the release action --- .github/workflows/build-wiki-pdf.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index efe1d17c06..356cb9d7de 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -24,7 +24,6 @@ jobs: git remote set-url origin https://${GITHUB_TOKEN}@github.com/utwente-fmt/vercors.git git push --force --tags - name: Create Wiki PDF release - if: ${{ github.ref == 'refs/heads/dev' }} uses: ncipollo/release-action@v1 with: allowUpdates: true From dfac27a6c3490f53b35c3606f1bc964661565301 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Mon, 1 Nov 2021 09:10:23 +0100 Subject: [PATCH 05/13] Pull out shared options into a function and add --toc-depth --- util/wiki/generate_wiki_pdf.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/util/wiki/generate_wiki_pdf.py b/util/wiki/generate_wiki_pdf.py index e2bd85e0c1..15261cd2fb 100755 --- a/util/wiki/generate_wiki_pdf.py +++ b/util/wiki/generate_wiki_pdf.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import re import subprocess import tempfile @@ -267,6 +268,10 @@ def output_menu(path, blocks, version): f.write("\n") f.write("\n") +def shared_pandoc_opts(generate_toc): + return ((["--toc", "--toc-depth", "2"] if generate_toc else []) + + [ "--metadata", "title=VerCors Tutorial" ]) + def output_pdf(path, blocks, version, generate_toc=True): wiki_text = json.dumps({ 'blocks': blocks, @@ -274,14 +279,12 @@ def output_pdf(path, blocks, version, generate_toc=True): 'meta': {}, }) - toc_option = ["--toc"] if generate_toc else [] - pypandoc.convert_text( wiki_text, "pdf", format="json", outputfile=path, - extra_args=toc_option + ["--pdf-engine=xelatex"]) + extra_args=shared_pandoc_opts(generate_toc) + ["--pdf-engine=xelatex"]) def output_html(path, blocks, version, generate_toc=True): wiki_text = json.dumps({ @@ -290,14 +293,12 @@ def output_html(path, blocks, version, generate_toc=True): 'meta': {} }) - toc_option = ["--toc", "--toc-depth", "2"] if generate_toc else [] - pypandoc.convert_text( wiki_text, "html", format="json", outputfile=path, - extra_args=toc_option + ["-s", "--template", "wiki_template.html", "--metadata", "title=VerCors Tutorial"]) + extra_args=shared_pandoc_opts(generate_toc) + ["-s", "--template", "wiki_template.html"]) if __name__ == "__main__": # TODO: Check if pypandoc is installed From d080934a82af0f26c298e40a4003b4dcf6cb03ca Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Mon, 1 Nov 2021 09:15:06 +0100 Subject: [PATCH 06/13] Add html generation to workflow --- .github/workflows/build-wiki-pdf.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index 356cb9d7de..a37093ac54 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -11,7 +11,10 @@ jobs: - working-directory: util/wiki run: pip3 install -r requirements.txt - working-directory: util/wiki - run: python3 ./generate_wiki_pdf.py --pdf wiki.pdf + run: | + git clone https://github.com/utwente-fmt/vercors.wiki.git + python3 ./generate_wiki_pdf.py -i vercors.wiki --pdf wiki.pdf + python3 ./generate_wiki_pdf.py -i vercors.wiki --html wiki.html - working-directory: util/wiki run: ls - name: Set wiki pdf tag in github repo @@ -20,17 +23,17 @@ jobs: run: | git config --local user.name "Vercors Team" git config --local user.email "vercors@lists.utwente.nl" - git tag --force wiki-pdf + git tag --force wiki-generated-doc git remote set-url origin https://${GITHUB_TOKEN}@github.com/utwente-fmt/vercors.git git push --force --tags - name: Create Wiki PDF release uses: ncipollo/release-action@v1 with: allowUpdates: true - artifacts: "util/wiki/*.pdf" + artifacts: "util/wiki/*.pdf,util/wiki/*.html" artifactContentType: application/pdf - body: This is an automatically generated LaTeX/PDF version of the tutorial on the VerCors wiki. + body: These are automatically generated versions of the tutorial on the VerCors wiki. There are two artefacts of interest: the Latex/PDF version, suitable for printing, and the HTML version, suitable for offline viewing. name: VerCors Wiki PDF prerelease: true - tag: wiki-pdf + tag: wiki-generated-doc token: ${{ secrets.GITHUB_TOKEN }} From 87c29ae31163e185af14ad80e542a5a1d52bf415 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Mon, 1 Nov 2021 09:20:15 +0100 Subject: [PATCH 07/13] Quote string --- .github/workflows/build-wiki-pdf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index a37093ac54..4b8ba92c75 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -32,7 +32,7 @@ jobs: allowUpdates: true artifacts: "util/wiki/*.pdf,util/wiki/*.html" artifactContentType: application/pdf - body: These are automatically generated versions of the tutorial on the VerCors wiki. There are two artefacts of interest: the Latex/PDF version, suitable for printing, and the HTML version, suitable for offline viewing. + body: "These are automatically generated versions of the tutorial on the VerCors wiki. There are two artefacts of interest: the Latex/PDF version, suitable for printing, and the HTML version, suitable for offline viewing." name: VerCors Wiki PDF prerelease: true tag: wiki-generated-doc From 377cdd6d19b139fd8fd6d603bcd5aa2bfbcc5924 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Mon, 1 Nov 2021 09:34:32 +0100 Subject: [PATCH 08/13] Turn arguments around and add a newline in the hope that the github actions error disappears... --- util/wiki/generate_wiki_pdf.py | 2 +- util/wiki/wiki_template.html | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/util/wiki/generate_wiki_pdf.py b/util/wiki/generate_wiki_pdf.py index 15261cd2fb..efe0deacf2 100755 --- a/util/wiki/generate_wiki_pdf.py +++ b/util/wiki/generate_wiki_pdf.py @@ -298,7 +298,7 @@ def output_html(path, blocks, version, generate_toc=True): "html", format="json", outputfile=path, - extra_args=shared_pandoc_opts(generate_toc) + ["-s", "--template", "wiki_template.html"]) + extra_args=["-s", "--template", "wiki_template.html"] + shared_pandoc_opts(generate_toc)) if __name__ == "__main__": # TODO: Check if pypandoc is installed diff --git a/util/wiki/wiki_template.html b/util/wiki/wiki_template.html index e40ca1bf21..4958b5692b 100644 --- a/util/wiki/wiki_template.html +++ b/util/wiki/wiki_template.html @@ -21,7 +21,9 @@ $endif$ $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ + """ + pypandoc.convert_text( wiki_text, "html", format="json", outputfile=path, - extra_args=["-s", "--template", "wiki_template.html"] + shared_pandoc_opts(generate_toc)) + extra_args=["-s", "-V", f"header-includes={header_includes}"] + shared_pandoc_opts(generate_toc)) if __name__ == "__main__": # TODO: Check if pypandoc is installed From 6539bcfc52288c5df8e0ae69be20f44cfbfa8761 Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Mon, 1 Nov 2021 10:06:37 +0100 Subject: [PATCH 12/13] Reinstate pdf generation and add centering to css --- .github/workflows/build-wiki-pdf.yml | 9 ++-- util/wiki/generate_wiki_pdf.py | 1 + util/wiki/wiki_template.html | 75 ---------------------------- 3 files changed, 6 insertions(+), 79 deletions(-) delete mode 100644 util/wiki/wiki_template.html diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index 72ab74746d..828899350a 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -10,10 +10,11 @@ jobs: - run: sudo apt install pandoc texlive-xetex - working-directory: util/wiki run: pip3 install -r requirements.txt + - run: pandoc --version - working-directory: util/wiki - run: "git clone https://github.com/utwente-fmt/vercors.wiki.git" - - working-directory: util/wiki - run: "python3 ./generate_wiki_pdf.py -i vercors.wiki --html wiki.html" + run: | + git clone https://github.com/utwente-fmt/vercors.wiki.git + python3 ./generate_wiki_pdf.py -i vercors.wiki --html wiki.html --pdf wiki.pdf - working-directory: util/wiki run: ls - name: Set wiki pdf tag in github repo @@ -29,7 +30,7 @@ jobs: uses: ncipollo/release-action@v1 with: allowUpdates: true - artifacts: "util/wiki/*.pdf,util/wiki/*.html" + artifacts: "util/wiki/wiki.pdf,util/wiki/wiki.html" artifactContentType: application/pdf body: "These are automatically generated versions of the tutorial on the VerCors wiki. There are two artefacts of interest: the Latex/PDF version, suitable for printing, and the HTML version, suitable for offline viewing." name: VerCors Wiki PDF diff --git a/util/wiki/generate_wiki_pdf.py b/util/wiki/generate_wiki_pdf.py index 4bdb53ace1..785981a5de 100755 --- a/util/wiki/generate_wiki_pdf.py +++ b/util/wiki/generate_wiki_pdf.py @@ -297,6 +297,7 @@ def output_html(path, blocks, version, generate_toc=True): """ diff --git a/util/wiki/wiki_template.html b/util/wiki/wiki_template.html deleted file mode 100644 index 4958b5692b..0000000000 --- a/util/wiki/wiki_template.html +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - -$for(author-meta)$ - -$endfor$ -$if(date-meta)$ - -$endif$ -$if(keywords)$ - -$endif$ -$if(description-meta)$ - -$endif$ - $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ - -$for(css)$ - -$endfor$ -$if(math)$ - $math$ -$endif$ - -$for(header-includes)$ - $header-includes$ -$endfor$ - - -$for(include-before)$ -$include-before$ -$endfor$ -$if(title)$ -
-

$title$

-$if(subtitle)$ -

$subtitle$

-$endif$ -$for(author)$ -

$author$

-$endfor$ -$if(date)$ -

$date$

-$endif$ -
-$endif$ -$if(toc)$ - -$endif$ -$body$ -$for(include-after)$ -$include-after$ -$endfor$ - - From 52670011cce5635dd81383359e65b0e96071390f Mon Sep 17 00:00:00 2001 From: Bob Rubbens Date: Mon, 1 Nov 2021 10:15:01 +0100 Subject: [PATCH 13/13] Set pdf action to only run on wiki change --- .github/workflows/build-wiki-pdf.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-wiki-pdf.yml b/.github/workflows/build-wiki-pdf.yml index 828899350a..c16f2d53cd 100644 --- a/.github/workflows/build-wiki-pdf.yml +++ b/.github/workflows/build-wiki-pdf.yml @@ -1,6 +1,6 @@ name: Vercors wiki pdf workflow # Only run when the wiki is updated -on: push +on: gollum jobs: make_pdf: runs-on: ubuntu-latest