Skip to content

Commit

Permalink
Merge pull request #38 from DILCISBoard/feat/pdf-publication
Browse files Browse the repository at this point in the history
FEAT - PDF publication for v2.0.1
  • Loading branch information
carlwilson authored Sep 11, 2019
2 parents 5ebe2f2 + 6496cb6 commit 51f3a1e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 18 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ script:
- java -jar target/mets-profile-proc.jar ../profile/E-ARK-DIP.xml
- cd ..
- bash create-site.sh
- bash create-pdf.sh
- bundle install
- bundle exec jekyll build -s ./docs -d ./_site
- bundle exec htmlproofer ./_site --file-ignore /javadoc/ --only-4xx --check-html
- cd spec-publisher
- git checkout feat/pdf-publication
- mvn clean package
- java -jar target/mets-profile-proc.jar ../profile/E-ARK-DIP.xml
- cd ..
- bash create-pdf.sh
deploy:
provider: pages
skip_cleanup: true
Expand Down
2 changes: 1 addition & 1 deletion PDF.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
!INCLUDE "spec-publisher/res/md/common-intro.md"
!INCLUDE "specification/metadata.md"

!INCLUDE "specification/index.md"
79 changes: 63 additions & 16 deletions create-pdf.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,32 +1,79 @@
#!/usr/bin/env bash
#!/usr/bin/env bash
echo "Generating PDF document from markdown"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR" || exit

if [ ! -d ~/.pandoc/templates ]
then
mkdir -p ~/.pandoc/templates
fi
cp spec-publisher/pandoc/templates/eisvogel.latex ~/.pandoc/templates/eisvogel.latex
cd "./specification/postface/"
bash "$SCRIPT_DIR/spec-publisher/utils/create-venv.sh"
command -v markdown-pp >/dev/null 2>&1 || {
tmpdir=$(dirname $(mktemp -u))
source "$tmpdir/.venv-markdown/bin/activate"
}
echo " - MARKDOWN-PP: Processing postface markdown"
markdown-pp postface.md -o "$SCRIPT_DIR/docs/postface.md" -e tableofcontents

cd "$SCRIPT_DIR/docs" || exit

echo " - PANDOC: Generating Preface from markdown"
pandoc --from gfm \
--to latex \
--metadata-file "../spec-publisher/pandoc/metadata.yaml" \
"../spec-publisher/res/md/common-intro.md" \
-o ./preface.tex
echo " - PANDOC: Finished"
sed -i 's%fig_1_dip.svg%fig_1_dip.png%' ./preface.tex
sed -i 's%section{%section*{%' ./preface.tex

echo " - PANDOC: Generating Postface from markdown"
pandoc --from gfm \
--to latex \
--metadata-file "../spec-publisher/pandoc/metadata.yaml" \
"$SCRIPT_DIR/docs/postface.md" \
-o ./postface.tex
sed -i 's%section{%section*{%' ./postface.tex
rm "$SCRIPT_DIR/docs/postface.md"

if [ ! -d "$SCRIPT_DIR/docs/pdf" ]
then
mkdir -p "$SCRIPT_DIR/docs/pdf/"
fi

bash "$SCRIPT_DIR/spec-publisher/utils/create-venv.sh"
source "$SCRIPT_DIR/.venv/markdown/bin/activate"
cd "$SCRIPT_DIR" || exit

echo " - MARKDOWN-PP: Preparing PDF markdown"
command -v markdown-pp >/dev/null 2>&1 || {
tmpdir=$(dirname $(mktemp -u))
source "$tmpdir/.venv-markdown/bin/activate"
}
markdown-pp PDF.md -o docs/eark-dip-pdf.md -e tableofcontents
deactivate

cp -R specification/media docs/
cp -R spec-publisher/res/md/figs docs/

cd docs || exit
pandoc --from gfm \
--template eisvogel \

###
# Pandoc options:
# --from markdown \ # Source fromat Markdown
# --template ../pandoc/templates/eisvogel.latex \ # Use this latex template
# --listings \ # Use listings package for code blocks
# --table-of-contents \ # Generate table of contents
# --metadata-file ../pandoc/metadata.yaml \ # Additional Pandoc metadata
# --include-before-body "../spec-publisher/res/md/common-intro.md" \
# --include-after-body "../specification/postface/postface.md" \
# --number-sections \ # Generate Heading Numbers
# eark-sip-pdf.md \ # Input Markdown file
# -o ./pdf/eark-dip.pdf # PDF Destinaton
echo " - PANDOC: Generating PDF document from markdown"
pandoc --from markdown \
--template "../spec-publisher/pandoc/templates/eisvogel.latex" \
--listings \
--toc \
--table-of-contents \
--metadata-file "../spec-publisher/pandoc/metadata.yaml" \
--include-before-body "./preface.tex" \
--include-after-body "./postface.tex" \
--number-sections \
eark-dip-pdf.md \
--metadata-file ../pandoc/metadata.yaml \
-o pdf/eark-dip.pdf

-o "./pdf/eark-dip.pdf"
echo "PANDOC: Finished"
rm "$SCRIPT_DIR/docs/preface.tex" "$SCRIPT_DIR/docs/postface.tex" "$SCRIPT_DIR/docs/eark-dip-pdf.md"
cd "$SCRIPT_DIR" || exit

0 comments on commit 51f3a1e

Please sign in to comment.