From 399651ce59692965f20d8cca72ef00d487d3289e Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Sun, 28 Jun 2020 23:59:13 +0200 Subject: [PATCH 01/10] #40 added build script --- build.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..6a49098 --- /dev/null +++ b/build.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# cleanup +latexmk -C +if [ -f chapter/out.tex ] +then + rm chapter/out.md + rm chapter/out.tex +fi + +# run pandoc +if [ $1 == "pandoc"] +then + cat chapter/*.md > chapter/out.md + pandoc --filter pandoc-citeproc --filter pandoc-crossref \ + -M cref=true --top-level-division=chapter \ + --bibliography library/library.bib --biblatex \ + -o chapter/out.tex chapter/out.md +fi + +# run latex build +if [ $1 != "clean" ] +then + latexmk -latexoption="-shell-escape" main.tex +fi From 423173aae4dbdb1b47d9bce0de5c4b6a15118d36 Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Sun, 28 Jun 2020 23:59:37 +0200 Subject: [PATCH 02/10] #40 configured build script for GitLab CI and Azure Pipelines --- latex.azure-pipelines.yml | 4 ++-- latex.gitlab-ci.yml | 2 +- markdown.azure-pipelines.yml | 6 ++---- markdown.gitlab-ci.yml | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/latex.azure-pipelines.yml b/latex.azure-pipelines.yml index e273160..2be1a88 100644 --- a/latex.azure-pipelines.yml +++ b/latex.azure-pipelines.yml @@ -23,8 +23,8 @@ stages: - job: latexmk container: fastexitlane/pandoc-latex:latest steps: - - script: latexmk main.tex - displayName: Execute LaTex Build + - script: ./build.sh + displayName: Run Build Script - task: PublishBuildArtifacts@1 inputs: ArtifactName: main.pdf diff --git a/latex.gitlab-ci.yml b/latex.gitlab-ci.yml index 72ed292..64e09fc 100644 --- a/latex.gitlab-ci.yml +++ b/latex.gitlab-ci.yml @@ -10,7 +10,7 @@ latexmk: - main*.pdf expire_in: 2d script: - - latexmk main.tex + - ./build.sh - ci_commit_sha_short=`git rev-parse --short $CI_COMMIT_SHA` - mv main.pdf main@$ci_commit_sha_short.pdf diff --git a/markdown.azure-pipelines.yml b/markdown.azure-pipelines.yml index b3fc7d2..2333265 100644 --- a/markdown.azure-pipelines.yml +++ b/markdown.azure-pipelines.yml @@ -22,10 +22,8 @@ stages: jobs: - job: pandoc_latexmk steps: - - script: pandoc --filter pandoc-crossref --filter pandoc-citeproc -M cref=true --top-level-division=chapter --bibliography library/library.bib --biblatex -o chapter/out.tex chapter/*.md - displayName: Convert Markdown Files to LaTex - - script: latexmk main.tex - displayName: Execute LaTex Build + - script: ./build.sh pandoc + displayName: Run Build Script with Pandoc Option - task: PublishBuildArtifacts@1 inputs: ArtifactName: main.pdf diff --git a/markdown.gitlab-ci.yml b/markdown.gitlab-ci.yml index 68de987..b7b5922 100644 --- a/markdown.gitlab-ci.yml +++ b/markdown.gitlab-ci.yml @@ -11,8 +11,7 @@ pandoc_latexmk: - main*.pdf expire_in: 2d script: - - pandoc --filter pandoc-crossref --filter pandoc-citeproc -M cref=true --top-level-division=chapter --bibliography library/library.bib --biblatex -o chapter/out.tex chapter/*.md - - latexmk main.tex + - ./build.sh pandoc - ci_commit_sha_short=`git rev-parse --short $CI_COMMIT_SHA` - mv main.pdf main@$ci_commit_sha_short.pdf From 874aab237af111d0a7e83cbcc5dc1324ef6e4349 Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Sun, 28 Jun 2020 23:59:47 +0200 Subject: [PATCH 03/10] #40 configured build script for VS Code --- .vscode/tasks.json | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d6c252c..5c95be7 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,7 +6,7 @@ { "label": "latexmk", "type": "shell", - "command": "latexmk -latexoption=\"-shell-escape\" main.tex", + "command": "${workspaceFolder}/build.sh", "group": { "kind": "build", "isDefault": true @@ -17,17 +17,8 @@ { "label": "clean", "type": "shell", - "command": "latexmk -C; if [ -f chapter/out.tex ]; then rm chapter/out.tex; fi" - }, - { - "label": "pandoc", - "type": "shell", - "command": [ - "pandoc --filter pandoc-crossref --filter pandoc-citeproc ", - "-M cref=true --top-level-division=chapter ", - "--bibliography library/library.bib --biblatex ", - "-o chapter/out.tex chapter/*.md" - ] + "command": "${workspaceFolder}/build.sh clean", + "group": "none", } ] } \ No newline at end of file From 98d27d793b78258d53eb0e0911365a824a830671 Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Mon, 29 Jun 2020 00:00:55 +0200 Subject: [PATCH 04/10] #40 added concated markdown file to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7b8b3d8..45d2c1f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ temp/ ## main build output main.pdf chapter/out.tex +chapter/out.md ## IDE and Editor files .idea/** From 8bbfee292ed46da3ed678a5a6164238d1ab8171c Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Mon, 29 Jun 2020 00:01:12 +0200 Subject: [PATCH 05/10] #43 added pandoc parameters for lists to config --- config.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config.tex b/config.tex index ccc2d49..f9c2acd 100644 --- a/config.tex +++ b/config.tex @@ -201,3 +201,7 @@ % Verbessert das Referenzieren von Kapiteln, Abbildungen etc. \usepackage[german,capitalise]{cleveref} + +% Pandoc Integration +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} From 6a58b7b13088f7569a47f222d9d510e804632b38 Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Mon, 29 Jun 2020 22:28:44 +0200 Subject: [PATCH 06/10] #40 added setup script to init repo --- .gitignore | 1 + setup.sh | 25 +++++++++++++++++++ .../latex.azure-pipelines.yml | 0 .../latex.gitlab-ci.yml | 0 .../tasks.json => templates/latex.tasks.json | 0 .../markdown.azure-pipelines.yml | 0 .../markdown.gitlab-ci.yml | 0 templates/markdown.tasks.json | 24 ++++++++++++++++++ 8 files changed, 50 insertions(+) create mode 100755 setup.sh rename latex.azure-pipelines.yml => templates/latex.azure-pipelines.yml (100%) rename latex.gitlab-ci.yml => templates/latex.gitlab-ci.yml (100%) rename .vscode/tasks.json => templates/latex.tasks.json (100%) rename markdown.azure-pipelines.yml => templates/markdown.azure-pipelines.yml (100%) rename markdown.gitlab-ci.yml => templates/markdown.gitlab-ci.yml (100%) create mode 100644 templates/markdown.tasks.json diff --git a/.gitignore b/.gitignore index 45d2c1f..f8c2b5e 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ chapter/out.md *.iml .sublime-project .sublime-workspace +.vscode/tasks.json ## MS Office Temp Files ~$*.ppt* diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..606e578 --- /dev/null +++ b/setup.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +function write_help { + echo "Usage:" + echo " ./setup.sh markdown Setup Boilerplate for usage with Markdown" + echo " ./setup.sh latex Setup Boilerplate for usage with LaTex" +} + +if [ $# == 0 ] +then + write_help + exit 1 +fi + +if [ $1 == "markdown" ] +then + cp templates/markdown.gitlab-ci.yml ./.gitlab-ci.yml + cp templates/markdown.tasks.json ./.vscode/tasks.json +elif [ $1 == "latex" ] +then + cp templates/latex.gitlab-ci.yml ./.gitlab-ci.yml + cp templates/latex.tasks.json ./.vscode/tasks.json +else + write_help +fi diff --git a/latex.azure-pipelines.yml b/templates/latex.azure-pipelines.yml similarity index 100% rename from latex.azure-pipelines.yml rename to templates/latex.azure-pipelines.yml diff --git a/latex.gitlab-ci.yml b/templates/latex.gitlab-ci.yml similarity index 100% rename from latex.gitlab-ci.yml rename to templates/latex.gitlab-ci.yml diff --git a/.vscode/tasks.json b/templates/latex.tasks.json similarity index 100% rename from .vscode/tasks.json rename to templates/latex.tasks.json diff --git a/markdown.azure-pipelines.yml b/templates/markdown.azure-pipelines.yml similarity index 100% rename from markdown.azure-pipelines.yml rename to templates/markdown.azure-pipelines.yml diff --git a/markdown.gitlab-ci.yml b/templates/markdown.gitlab-ci.yml similarity index 100% rename from markdown.gitlab-ci.yml rename to templates/markdown.gitlab-ci.yml diff --git a/templates/markdown.tasks.json b/templates/markdown.tasks.json new file mode 100644 index 0000000..ecfae69 --- /dev/null +++ b/templates/markdown.tasks.json @@ -0,0 +1,24 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "latexmk", + "type": "shell", + "command": "${workspaceFolder}/build.sh pandoc", + "group": { + "kind": "build", + "isDefault": true + }, + "dependsOrder": "sequence", + "dependsOn": ["clean"] + }, + { + "label": "clean", + "type": "shell", + "command": "${workspaceFolder}/build.sh clean", + "group": "none", + } + ] +} \ No newline at end of file From 8f20dca902f6bc079d5d589ddd6d56ec747dc9c7 Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Mon, 29 Jun 2020 22:28:55 +0200 Subject: [PATCH 07/10] #40 added setup script to init repo --- setup.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.sh b/setup.sh index 606e578..49f51c0 100755 --- a/setup.sh +++ b/setup.sh @@ -15,10 +15,12 @@ fi if [ $1 == "markdown" ] then cp templates/markdown.gitlab-ci.yml ./.gitlab-ci.yml + cp templates/markdown.azure-pipelines.yml ./azure-pipelines.yml cp templates/markdown.tasks.json ./.vscode/tasks.json elif [ $1 == "latex" ] then cp templates/latex.gitlab-ci.yml ./.gitlab-ci.yml + cp templates/latex.azure-pipelines.yml ./azure-pipelines.yml cp templates/latex.tasks.json ./.vscode/tasks.json else write_help From 4c11c1d73261f746c0c2d4c5637594854b2154b8 Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Mon, 29 Jun 2020 22:31:14 +0200 Subject: [PATCH 08/10] #40 included main.tex in setup script --- setup.sh | 1 + templates/markdown.main.tex | 80 +++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 templates/markdown.main.tex diff --git a/setup.sh b/setup.sh index 49f51c0..4066f4c 100755 --- a/setup.sh +++ b/setup.sh @@ -17,6 +17,7 @@ then cp templates/markdown.gitlab-ci.yml ./.gitlab-ci.yml cp templates/markdown.azure-pipelines.yml ./azure-pipelines.yml cp templates/markdown.tasks.json ./.vscode/tasks.json + cp templates/markdown.main.tex ./main.tex elif [ $1 == "latex" ] then cp templates/latex.gitlab-ci.yml ./.gitlab-ci.yml diff --git a/templates/markdown.main.tex b/templates/markdown.main.tex new file mode 100644 index 0000000..bd6ae1e --- /dev/null +++ b/templates/markdown.main.tex @@ -0,0 +1,80 @@ +% Makros +\newcommand{\dokumententyp}{Dokumententyp} +\newcommand{\abgabedatum}{\today} +\newcommand{\ort}{Ort} +\newcommand{\dokumententitel}{Titel} +\newcommand{\dokumentenuntertitel}{Untertitel} +\newcommand{\dokumentenautor}{Autor} +\newcommand{\matrikelnr}{Matrikel-Nr.} +\newcommand{\dokumentenautoradresse}{Adresse} +\newcommand{\dokumentenpruefer}{Prüfer} +\newcommand{\studiengang}{Studiengang} +\newcommand{\studiengruppe}{Studiengruppe} +\newcommand{\institution}{Institution} + +% config +\input{config.tex} + +\begin{document} + %%%%%%%%%%%%%%%%%%%%%%%%% + %% document title page %% + %%%%%%%%%%%%%%%%%%%%%%%%% + \input{additionals/title.tex} + + %%%%%%%%%%%%% + %% indexes %% + %%%%%%%%%%%%% + \pagenumbering{Roman} + + % disclosure statement - uncomment if needed + % \input{additionals/disclosure.tex} + % \newpage + + % executive summary - uncomment if needed + % \input{additionals/executive_summary.tex} + % \newpage + + % table of contents + \tableofcontents + \newpage + + % acronyms + \input{additionals/acronyms.tex} + \newpage + + % list of figures + \listoffigures + \newpage + + % list of tables + \listoftables + \newpage + + % list of listings + \listoflistings + \newpage + + %%%%%%%%%%%%% + %% content %% + %%%%%%%%%%%%% + \pagenumbering{arabic} + + % when using pandoc workflow, we only need to include the build output + \input{chapter/out.tex} + \newpage + + %%%%%%%%%%%%% + %% closing %% + %%%%%%%%%%%%% + % list of references + \input{additionals/references.tex} + \newpage + + % appendix - uncomment if needed + % \input{appendix/appendix.tex} + % \newpage + + % affirmation + \input{additionals/affirmation.tex} + +\end{document} From 686dff998ad1d94768a2af954b4fdd6fae863aea Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Mon, 29 Jun 2020 22:38:51 +0200 Subject: [PATCH 09/10] #40 added quick start guide for setup script --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9f090f9..8f21551 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,19 @@ git pull boilerplate master git remote remove boilerplate ``` -In order to use the preconfigured CI / CD pipeline for building PDFs, copy either `latex.gitlab-ci.yml` or `markdown.gitlab-ci.yml` to `.gitlab-ci`, depending on which workflow you want to use. -On GitLab.com, this will use Dockerized builds by default. -If you want to use the workflow on own hardware, make sure your GitLab CI meets the [Basic Requirements](https://gitlab.com/fastexitlane/latex-boilerplate/wikis/GitLab-CI#basic-requirements). +In order to setup the repo for CI / CD on GitLab and Azurre DevOps, as well as VS Code integration, run `setup.sh latex` or `setup.sh markdown`, depending in which workflow you want to use. +CI will use Dockerized builds by default. +If you want to use the workflow on GitLab, but with own hardware, make sure your GitLab CI meets the [Basic Requirements](https://gitlab.com/fastexitlane/latex-boilerplate/wikis/GitLab-CI#basic-requirements). If you know what you're doing, simply start adding your content files in `chapter/` as LaTex `\chapter`s and `\input` them into `main.tex`. +You can then run the build using VS Code preconfigured tasks or using `build.sh`. + +For Markdown, add your content as `*.md` files in `chapter/` and prefix them with ascending numbers. +You shouldn't need to `\input` or configure anything else, as the files are concatenated automatically at build time. + If you do not know what you're doing or get into trouble - or want to use the **Markdown Workflow**, you may want to consider the [wiki](https://gitlab.com/fastexitlane/latex-boilerplate/wikis/home) ;-) ## Docker Images If you need a Docker image to build your documents, head over to [pandoc-latex](https://github.com/fastexitlane/pandoc-latex) ([DockerHub](https://hub.docker.com/r/fastexitlane/pandoc-latex)). -Also, there's a prebuilt Docker image for spellchecking using Hunspell - head over to [docker-hunspell](https://github.com/fastexitlane/docker-hunspell). \ No newline at end of file +Also, there's a prebuilt Docker image for spellchecking using Hunspell - head over to [docker-hunspell](https://github.com/fastexitlane/docker-hunspell). From 4b242c2f428121a85454f222fba0366e030cb452 Mon Sep 17 00:00:00 2001 From: Dominik Becker Date: Mon, 29 Jun 2020 22:42:10 +0200 Subject: [PATCH 10/10] #40 added quick start guide for setup script --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f21551..9209705 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,9 @@ If you want to use the workflow on GitLab, but with own hardware, make sure your If you know what you're doing, simply start adding your content files in `chapter/` as LaTex `\chapter`s and `\input` them into `main.tex`. You can then run the build using VS Code preconfigured tasks or using `build.sh`. -For Markdown, add your content as `*.md` files in `chapter/` and prefix them with ascending numbers. +For Markdown, add your content as `*.md` files in `chapter/` and prefix them with ascending numbers (to keep chapter sequence). You shouldn't need to `\input` or configure anything else, as the files are concatenated automatically at build time. +Run `build.sh pandoc` to build your PDF. If you do not know what you're doing or get into trouble - or want to use the **Markdown Workflow**, you may want to consider the [wiki](https://gitlab.com/fastexitlane/latex-boilerplate/wikis/home) ;-)