Skip to content

Commit 20ed00d

Browse files
committed
More on pandoc pdf exporter
1 parent 2192be5 commit 20ed00d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

modules/exporters/pandoc/pdf.nix

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{ callPackage
2+
, coreutils
23
, pandoc
34
, texliveToUse
45
}:
@@ -18,8 +19,16 @@ common.writeShellScriptBinWithAttrs {
1819
} "export" ''
1920
echo_and_run() { echo "$*" ; "$@" ; }
2021
echo_and_run export PATH="''${PATH:+''${PATH}:}${pandoc}/bin:${texliveToUse}/bin"
21-
echo_and_run ${pandoc}/bin/pandoc -f markdown+tex_math_dollars+tex_math_single_backslash+raw_html+smart \
22-
-t pdf \
23-
"$1" \
24-
"-o" "$2"
22+
23+
filename=$(${coreutils}/bin/basename -- "$2")
24+
EXTENSION="''${filename##*.}"
25+
FILENAME="''${filename%.*}"
26+
27+
echo "Got extension: $EXTENSION"
28+
EXTRA_ARGS=""
29+
if [[ "$EXTENSION" == "md" ]]
30+
EXTRA_ARGS="-f markdown+tex_math_dollars+tex_math_single_backslash+raw_html+smart"
31+
fi
32+
33+
echo_and_run ${pandoc}/bin/pandoc $EXTRA_ARGS -t pdf "$1" -o "$2"
2534
''

0 commit comments

Comments
 (0)