Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP [ENH] pdf generating script #955

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions tools/pdf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
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 \
--toc \
--highlight-style haddock \
-o MNECPP.pdf \
--pdf-engine=xelatex \
-V geometry:top=.75in \
-V geometry:left=1in \
-V geometry:right=1in \
-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

rm -r doc2 media_dir