---
# yamllint disable rule:line-length

docs:pandoc-from-template:
  image:
    name: registry.gitlab.com/notno/pandoc
    entrypoint: [""]
  variables:
    FORMATS: pdf docx html
    DEFAULT_ARGS: >
      --standalone
      --table-of-contents
      --number-sections
      --citeproc
      --metadata link-citations=true
    PDF_ENGINE: xelatex
    SOURCE_DIR: .
    MEDIA_DIR: media
    BIBLIOGRAPHY: references.yaml
    TEMPLATE: https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/master/eisvogel.tex
    CSL: https://raw.githubusercontent.com/citation-style-language/styles/master/cell-numeric.csl
    CSS: https://gist.githubusercontent.com/killercup/5917178/raw/40840de5352083adb2693dc742e9f75dbb18650f/pandoc.css
    TOC_DEPTH: 2
    REPORT_NAME: "${CI_PROJECT_NAME}"
    METADATA_LANG: en-US
    EXTRA_ARGS: ""  # Add extra arguments to customize even further
  script:
    - mkdir output
    - |
      for FORMAT in $FORMATS; do
        pandoc ${DEFAULT_ARGS} ${EXTRA_ARGS} --template="${TEMPLATE}" --pdf-engine=${PDF_ENGINE} --csl="${CSL}" --css="${CSS}" --toc-depth=${TOC_DEPTH} --bibliography="${BIBLIOGRAPHY}" --extract-media="${OUTPUT_DIR}/${MEDIA_DIR}" --metadata lang=${METADATA_LANG} --to ${FORMAT} --output output/"${REPORT_NAME}.${FORMAT}" --resource-path=.:"${SOURCE_DIR}" "${SOURCE_DIR}"/*.md
      done
  artifacts:
    paths:
      - output/*
