From ef2d703f000d6d152df008f680d16372ece02b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Wed, 13 Jan 2021 23:52:50 +0100 Subject: [PATCH] Add simple script for markdown to pdf conversion --- bin/markdown-to-pdf | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 bin/markdown-to-pdf diff --git a/bin/markdown-to-pdf b/bin/markdown-to-pdf new file mode 100755 index 0000000..f5a26f9 --- /dev/null +++ b/bin/markdown-to-pdf @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +set -o nounset + +usage() { + cat <&2 +$0 +EOF +} + +if (( $# != 2 )) ; then + usage + exit 1 +fi + +markdown_extensions=( + blank_before_header + space_in_atx_header + blank_before_blockquote + yaml_metadata_block + backtick_code_blocks + fancy_lists + native_divs + fenced_divs + task_lists + pipe_tables +) + +function join_by { local d=$1; shift; local f=$1; shift; printf %s "$f" "${@/#/$d}"; } + +pandoc \ + --from markdown+"$(join_by "+" "${markdown_extensions[@]}")"\ + --to pdf \ + --verbose \ + --email-obfuscation=none \ + --columns=2000 \ + --fail-if-warnings \ + --standalone \ + --variable tables=true \ + --variable euro=yes \ + --variable colorlinks=yes \ + --variable linestretch=1.3 \ + --variable papersize=a4 \ + --variable date=$(date --iso-8601=date) \ + --variable fontsize=12pt \ + --variable fontfamily=libertine \ + --variable familydefault=sfdefault \ + --variable documentclass=scrartcl \ + --variable fontfamilyoptions= \ + --variable lof= \ + --variable lot= \ + -i "${1}" \ + --output "${2}" \