Add simple script for markdown to pdf conversion
This commit is contained in:
53
bin/markdown-to-pdf
Executable file
53
bin/markdown-to-pdf
Executable file
@@ -0,0 +1,53 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF >&2
|
||||||
|
$0 <input file> <output file>
|
||||||
|
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}" \
|
||||||
Reference in New Issue
Block a user