From 7ba8b5b814e36132ffc51f450e1972c9952b2d56 Mon Sep 17 00:00:00 2001 From: gabrielbmotta Date: Tue, 2 May 2023 14:37:22 -0400 Subject: [PATCH 1/5] First stab at a pdf generating script --- tools/pdf.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 tools/pdf.sh diff --git a/tools/pdf.sh b/tools/pdf.sh new file mode 100755 index 00000000000..66c02e70720 --- /dev/null +++ b/tools/pdf.sh @@ -0,0 +1,52 @@ +function cleanAbsPath() +{ + local cleanAbsPathStr="$( #spawns a new bash interpreter + cd "$1" >/dev/null 2>&1 #change directory to that folder + pwd -P + )" + echo "$cleanAbsPathStr" +} + +SCRIPT_PATH="$(cleanAbsPath "$(dirname "$0")")" +BASE_PATH="$(cleanAbsPath "${SCRIPT_PATH}/..")" + +cd $BASE_PATH + +SED_OS_DEPENDANT_FORMATTING="" + +if [ "$(uname)" == "Darwin" ]; then + SED_OS_DEPENDANT_FORMATTING="''" +fi + +cleanup() +{ + echo "Processing files in dir: $1" + for f in $1/*.md; do + echo " Processing: $f" + sed -i ${SED_OS_DEPENDANT_FORMATTING} '/---/,/---/d' $f + sed -i ${SED_OS_DEPENDANT_FORMATTING} 's/{:target="_blank" rel="noopener"}//g' $f + done +} + +cp -r doc doc2 + +cleanup doc2/gh-pages +cleanup doc2/gh-pages/pages/development +cleanup doc2/gh-pages/pages/documentation + +pandoc \ + doc2/gh-pages/*.md \ + doc2/gh-pages/pages/development/*.md \ + doc2/gh-pages/pages/documentation/*.md \ + -f gfm \ + -o test.pdf \ + --pdf-engine=xelatex \ + -V geometry:top=.75in \ + -V geometry:left=1in \ + -V geometry:right=1in \ + -V geometry:bottom=.75in \ + --extract-media=media_dir \ + --resource-path=doc2/gh-pages/images:doc2/gh-pages/images/lib:doc2/gh-pages/images/analyze + +rm -r doc2 + From eb57acda2a582455fa633fc590308fc433d7edf3 Mon Sep 17 00:00:00 2001 From: gabrielbmotta Date: Thu, 4 May 2023 13:52:42 -0400 Subject: [PATCH 2/5] Also clean up media folder after generating pdf --- tools/pdf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/pdf.sh b/tools/pdf.sh index 66c02e70720..39c356e0b4c 100755 --- a/tools/pdf.sh +++ b/tools/pdf.sh @@ -48,5 +48,5 @@ pandoc \ --extract-media=media_dir \ --resource-path=doc2/gh-pages/images:doc2/gh-pages/images/lib:doc2/gh-pages/images/analyze -rm -r doc2 +rm -r doc2 media_dir From d65b514db8e336da1a22e7e748d2bcb7fc8ef307 Mon Sep 17 00:00:00 2001 From: gabrielbmotta Date: Thu, 4 May 2023 14:28:15 -0400 Subject: [PATCH 3/5] Pass font to avoid missing unicode characters --- tools/pdf.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/pdf.sh b/tools/pdf.sh index 39c356e0b4c..9332859bbfb 100755 --- a/tools/pdf.sh +++ b/tools/pdf.sh @@ -39,12 +39,13 @@ pandoc \ doc2/gh-pages/pages/development/*.md \ doc2/gh-pages/pages/documentation/*.md \ -f gfm \ - -o test.pdf \ + -o MNECPP.pdf \ --pdf-engine=xelatex \ -V geometry:top=.75in \ -V geometry:left=1in \ -V geometry:right=1in \ -V geometry:bottom=.75in \ + -V 'monofont:Courier New' \ --extract-media=media_dir \ --resource-path=doc2/gh-pages/images:doc2/gh-pages/images/lib:doc2/gh-pages/images/analyze From e4c514e4d2288ddb5be50aa27d756623a5f8b0af Mon Sep 17 00:00:00 2001 From: gabrielbmotta Date: Fri, 12 May 2023 11:29:07 -0400 Subject: [PATCH 4/5] Add table of contents and update margin formatting. --- tools/pdf.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/pdf.sh b/tools/pdf.sh index 9332859bbfb..776d750a381 100755 --- a/tools/pdf.sh +++ b/tools/pdf.sh @@ -39,12 +39,13 @@ pandoc \ doc2/gh-pages/pages/development/*.md \ doc2/gh-pages/pages/documentation/*.md \ -f gfm \ + --toc \ -o MNECPP.pdf \ --pdf-engine=xelatex \ -V geometry:top=.75in \ -V geometry:left=1in \ -V geometry:right=1in \ - -V geometry:bottom=.75in \ + -V geometry:bottom=1in \ -V 'monofont:Courier New' \ --extract-media=media_dir \ --resource-path=doc2/gh-pages/images:doc2/gh-pages/images/lib:doc2/gh-pages/images/analyze From 90607c3458c5b2dcc1f865f120a057a20fb5d890 Mon Sep 17 00:00:00 2001 From: gabrielbmotta Date: Fri, 12 May 2023 13:51:36 -0400 Subject: [PATCH 5/5] Changing highlighting on markdown code blocks --- tools/pdf.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/pdf.sh b/tools/pdf.sh index 776d750a381..bc158495560 100755 --- a/tools/pdf.sh +++ b/tools/pdf.sh @@ -40,6 +40,7 @@ pandoc \ doc2/gh-pages/pages/documentation/*.md \ -f gfm \ --toc \ + --highlight-style haddock \ -o MNECPP.pdf \ --pdf-engine=xelatex \ -V geometry:top=.75in \ @@ -49,6 +50,6 @@ pandoc \ -V 'monofont:Courier New' \ --extract-media=media_dir \ --resource-path=doc2/gh-pages/images:doc2/gh-pages/images/lib:doc2/gh-pages/images/analyze - + rm -r doc2 media_dir