Adjust to personal needs

This commit is contained in:
KingOfDog 2021-05-16 22:01:36 +02:00
parent cf6cb99174
commit 2e703347d6
13 changed files with 135 additions and 39 deletions

18
build.sh Executable file → Normal file
View File

@ -3,24 +3,24 @@
function run_clean {
latexmk -C
if [ -f main.bbl ]
if [ -f out/main.bbl ]
then
rm main.bbl
rm out/main.bbl
fi
if [ -f main.lol ]
if [ -f out/main.lol ]
then
rm main.lol
rm out/main.lol
fi
if [ -f main.ptc ]
if [ -f out/main.ptc ]
then
rm main.ptc
rm out/main.ptc
fi
if [ -f main.run.xml ]
if [ -f out/main.run.xml ]
then
rm main.run.xml
rm out/main.run.xml
fi
if [ -f chapter/out.tex ]
@ -51,7 +51,7 @@ function run_pandoc {
}
function run_latexmk {
latexmk -latexoption="-shell-escape" main.tex
latexmk -quiet -latexoption="-shell-escape" -outdir=out main.tex
}
function run_pandoc_appendix {

View File

@ -14,13 +14,15 @@ 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
cp templates/markdown.main.tex ./main.tex
#cp templates/markdown.gitlab-ci.yml ./.gitlab-ci.yml
cp templates/markdown/.drone.yml ./.drone.yml
#cp templates/markdown/github-workflow.yml ./.github/workflows/latex.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
#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

View File

@ -1,24 +0,0 @@
{
// 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",
}
]
}

View File

@ -0,0 +1,46 @@
kind: pipeline
type: docker
name: test
steps:
- name: hunspell_chapters
image: fastexitlane/hunspell:latest
commands:
- export HUNSPELL_FINDINGS=`for filename in chapter/*.md; do hunspell -l -d de_DE_frami,en_US -p ./.hunspellignore $filename; done | sort | uniq`
- echo $HUNSPELL_FINDINGS
- '[ -z "$HUNSPELL_FINDINGS" ] && exit 0 || exit 1'
failure: ignore
- name: hunspell_appendix
image: fastexitlane/hunspell:latest
commands:
- export HUNSPELL_FINDINGS=`for filename in appendix/*.tex; do hunspell -l -d de_DE_frami,en_US -p ./.hunspellignore -t $filename; done | sort | uniq`
- echo $HUNSPELL_FINDINGS
- '[ -z "$HUNSPELL_FINDINGS" ] && exit 0 || exit 1'
failure: ignore
---
kind: pipeline
type: docker
name: build
steps:
- name: pandoc
image: fastexitlane/pandoc-latex:latest
commands:
- ./build.sh pandoc
- ci_commit_sha_short=`git rev-parse --short $CI_COMMIT_SHA`
- name: gitea_release
image: plugins/gitea-release
settings:
api_key:
from_secret: gitea_token
base_url: https://git.kingofdog.de
files:
- main.pdf
when:
event:
- tag
trigger:
branch:
- main

View File

View File

@ -0,0 +1,43 @@
{
// 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": "docker run --rm -u 1000 -v '${workspaceFolder}:/work/' -w /work/ fastexitlane/pandoc-latex:latest ./build.sh pandoc",
"group": {
"kind": "build",
"isDefault": true
},
"dependsOrder": "sequence",
"dependsOn": [
"clean"
]
},
{
"label": "clean",
"type": "shell",
"command": "docker run --rm -u 1000 -v '${workspaceFolder}:/work/' -w /work/ fastexitlane/pandoc-latex:latest ./build.sh clean",
"group": "none"
},
{
"label": "wordcount",
"type": "shell",
"command": "docker run --rm -u 1000 -v '${workspaceFolder}:/work/' -w /work/ fastexitlane/pandoc-latex:latest pandoc --lua-filter=/work/wordcount.lua /work/chapter/out.md",
"group": "none",
"problemMatcher": []
},
{
"label": "overusedwords",
"type": "shell",
"command": "cat chapter/out.md | tr 'A-ZÄÖÜ' 'a-zäöü' | sed --regexp-extended 's/\\\\acf?s?p?\\{([^}]+)\\}/\\1/g' | sed 's/-/ /g' | sed 's/[^a-zäöü ]//g' | tr -s '[[:space:]]' '\\n' | sort | uniq -c | sort -nr | head -n100 > words.txt",
"windows": {
"command": "wsl cat chapter/out.md `| tr 'A-ZÄÖÜ' 'a-zäöü' `| sed 's/-/ /g' `| sed 's/[^a-zäöü]//g' `> words.txt"
},
"group": "none",
"problemMatcher": []
}
]
}

29
wordcount.lua Normal file
View File

@ -0,0 +1,29 @@
-- counts words in a document
words = 0
wordcount = {
Str = function(el)
-- we don't count a word if it's entirely punctuation:
if el.text:match("%P") then
words = words + 1
end
end,
Code = function(el)
_,n = el.text:gsub("%S+","")
words = words + n
end,
CodeBlock = function(el)
_,n = el.text:gsub("%S+","")
words = words + n
end
}
function Pandoc(el)
-- skip metadata, just count body:
pandoc.walk_block(pandoc.Div(el.blocks), wordcount)
print(words .. " words in body")
os.exit(0)
end