Corrected panda script for reveal
This commit is contained in:
+28
-10
@@ -7,8 +7,11 @@ if [ $# -lt 1 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set the filename
|
# Store original directory and move to input file's directory
|
||||||
FILENAME=$1
|
ORIG_DIR=$(pwd)
|
||||||
|
cd "$(dirname "$1")"
|
||||||
|
FILENAME=$(basename "$1")
|
||||||
|
CURRENT_DIR=$(pwd)
|
||||||
|
|
||||||
# Set the output format to html if not provided
|
# Set the output format to html if not provided
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
@@ -18,7 +21,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the input file exists
|
# Check if the input file exists
|
||||||
if [ ! -f $FILENAME ]; then
|
if [ ! -f "$FILENAME" ]; then
|
||||||
echo "Error: Input file '$FILENAME' does not exist."
|
echo "Error: Input file '$FILENAME' does not exist."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -27,18 +30,27 @@ fi
|
|||||||
case $OUTPUT_FORMAT in
|
case $OUTPUT_FORMAT in
|
||||||
pdf)
|
pdf)
|
||||||
FILE_EXT="pdf"
|
FILE_EXT="pdf"
|
||||||
OUTPUT_FORMAT="latex --variable fontsize:12pt"
|
OUTPUT_FORMAT="latex"
|
||||||
|
PANDOC_OPTS="--variable fontsize:12pt"
|
||||||
;;
|
;;
|
||||||
reveal)
|
reveal)
|
||||||
FILE_EXT="html"
|
FILE_EXT="html"
|
||||||
OUTPUT_FORMAT="revealjs --standalone --embed-resources -V revealjs-url='/home/ntnsndr/.revealjs/reveal.js' -V theme=ntn -V controls=false --slide-level=2"
|
OUTPUT_FORMAT="revealjs"
|
||||||
|
PANDOC_OPTS="--standalone --embed-resources -V revealjs-url=/home/ntnsndr/.revealjs/reveal.js -V theme=ntn -V controls=false --slide-level=2"
|
||||||
;;
|
;;
|
||||||
pptx)
|
pptx)
|
||||||
FILE_EXT="pptx"
|
FILE_EXT="pptx"
|
||||||
OUTPUT_FORMAT="pptx --reference-doc='/home/ntnsndr/.templates/Slideshow.pptx'"
|
OUTPUT_FORMAT="pptx"
|
||||||
|
PANDOC_OPTS="--reference-doc=/home/ntnsndr/.templates/Slideshow.pptx"
|
||||||
|
;;
|
||||||
|
html)
|
||||||
|
FILE_EXT="html"
|
||||||
|
OUTPUT_FORMAT="html"
|
||||||
|
PANDOC_OPTS="--embed-resources --standalone"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
FILE_EXT=$OUTPUT_FORMAT
|
FILE_EXT=$OUTPUT_FORMAT
|
||||||
|
PANDOC_OPTS=""
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -53,10 +65,17 @@ if [ ! -w /tmp ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the input file to the temporary file
|
# Copy the input file to the temporary file
|
||||||
cp $FILENAME $TMP_IN_FILE
|
cp "$FILENAME" "$TMP_IN_FILE"
|
||||||
|
|
||||||
# Convert the file using pandoc
|
# Convert the file using pandoc
|
||||||
iconv -t utf-8 $TMP_IN_FILE | pandoc -s -f markdown+smart --citeproc --bibliography $HOME/Zotero/lib.bib --pdf-engine=xelatex -t $OUTPUT_FORMAT -o $TMP_OUT_FILE
|
iconv -t utf-8 "$TMP_IN_FILE" | pandoc -s -f markdown+smart \
|
||||||
|
--citeproc --bibliography "$HOME/Zotero/lib.bib" \
|
||||||
|
--pdf-engine=xelatex \
|
||||||
|
--resource-path="$CURRENT_DIR" \
|
||||||
|
-t "$OUTPUT_FORMAT" $PANDOC_OPTS -o "$TMP_OUT_FILE"
|
||||||
|
|
||||||
|
# Return to original directory
|
||||||
|
cd "$ORIG_DIR"
|
||||||
|
|
||||||
# Check if the pandoc command is successful
|
# Check if the pandoc command is successful
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
@@ -65,11 +84,10 @@ if [ $? -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Open the output file
|
# Open the output file
|
||||||
xdg-open $TMP_OUT_FILE
|
xdg-open "$TMP_OUT_FILE"
|
||||||
|
|
||||||
# Check if the output file can be opened
|
# Check if the output file can be opened
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: Cannot open output file '$TMP_OUT_FILE'."
|
echo "Error: Cannot open output file '$TMP_OUT_FILE'."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user