Permalink
Browse files

Support BUILD_PDF=false environment variable

Merges #145
Closes #122

* Add BUILD_PDF environment variable
BUILD_PDF is considered "true" unless specifically set to "false"

webpage.py: tolerate missing output/manuscript.pdf
Refs #144 (comment)

ots stamp in deploy.sh: do not fail if BUILD_PDF=false

* Delete existing images symlink in PDF build script

When an images directory exists, do not create a symbolic link with
source images/images. More info in ln documentation:
- https://ss64.com/osx/ln.html
- https://linux.die.net/man/1/ln

Ignore /images temporary symlink
  • Loading branch information...
dhimmel committed Nov 9, 2018
1 parent 135f451 commit 44c5d35b86266606b22fdcfcb11d1bb064cda5c9
Showing with 42 additions and 29 deletions.
  1. +4 −0 .gitignore
  2. +4 −1 build/README.md
  3. +26 −24 build/build.sh
  4. +4 −1 build/webpage.py
  5. +4 −3 ci/deploy.sh
@@ -4,6 +4,10 @@ output/*

webpage/v

# When PDF building fails, a temporary symlink named images in the root
# directory is not removed.
/images

# Manubot cache directory
ci/cache

@@ -2,10 +2,13 @@

[`build.sh`](build.sh) builds the repository.
`sh build/build.sh` should be executed from the root directory of the repository.
By default, `build.sh` creates HTML and PDF outputs.
However, setting the `BUILD_PDF` environment variable to `false` will suppress PDF output.
For example, run local builds using the command `BUILD_PDF=false sh build/build.sh`.

To build a DOCX file of the manuscript, set the `BUILD_DOCX` environment variable to `true`.
For example, use the command `BUILD_DOCX=true sh build/build.sh`.
Set a [Travis environment variable](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings) to export DOCX for all Travis builds.
To export DOCX for all Travis builds, set a [Travis environment variable](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings).
Currently, equation numbers via `pandoc-eqnos` are not supported for DOCX output.
There is varying support for embedding images in DOCX output.
Please reference [Pull Request #40](https://github.com/greenelab/manubot-rootstock/pull/40) for possible solutions and continued discussion.
@@ -42,31 +42,33 @@ pandoc --verbose \
--output=output/manuscript.html \
$INPUT_PATH

# Create PDF output
echo "Exporting PDF manuscript"
ln -s content/images images
pandoc \
--from=markdown \
--to=html5 \
--pdf-engine=weasyprint \
--pdf-engine-opt=--presentational-hints \
--filter=pandoc-fignos \
--filter=pandoc-eqnos \
--filter=pandoc-tablenos \
--bibliography=$BIBLIOGRAPHY_PATH \
--csl=$CSL_PATH \
--metadata link-citations=true \
--webtex=https://latex.codecogs.com/svg.latex? \
--css=webpage/github-pandoc.css \
--output=output/manuscript.pdf \
$INPUT_PATH
rm -r images
# Create PDF output (unless BUILD_PDF environment variable equals "false")
if [ "$BUILD_PDF" != "false" ]; then
echo "Exporting PDF manuscript"
if [ -L images ]; then rm images; fi # if images is a symlink, remove it
ln -s content/images
pandoc \
--from=markdown \
--to=html5 \
--pdf-engine=weasyprint \
--pdf-engine-opt=--presentational-hints \
--filter=pandoc-fignos \
--filter=pandoc-eqnos \
--filter=pandoc-tablenos \
--bibliography=$BIBLIOGRAPHY_PATH \
--csl=$CSL_PATH \
--metadata link-citations=true \
--webtex=https://latex.codecogs.com/svg.latex? \
--css=webpage/github-pandoc.css \
--output=output/manuscript.pdf \
$INPUT_PATH
rm images
fi

# Create DOCX output when user specifies to do so
if [ "$BUILD_DOCX" = "true" ];
then
echo "Exporting Word Docx manuscript"
pandoc --verbose \
# Create DOCX output (if BUILD_DOCX environment variable equals "true")
if [ "$BUILD_DOCX" = "true" ]; then
echo "Exporting Word Docx manuscript"
pandoc --verbose \
--from=markdown \
--to=docx \
--filter=pandoc-fignos \
@@ -117,8 +117,11 @@ def create_version(args):
'manuscript.pdf': 'manuscript.pdf',
}
for src, dst in renamer.items():
src_path = args.output_directory.joinpath(src)
if not src_path.exists():
continue
shutil.copy2(
src=args.output_directory.joinpath(src),
src=src_path,
dst=args.version_directory.joinpath(dst),
)

@@ -35,9 +35,10 @@ python build/webpage.py \
--version=$TRAVIS_COMMIT

# Generate OpenTimestamps
ots stamp \
webpage/v/$TRAVIS_COMMIT/index.html \
webpage/v/$TRAVIS_COMMIT/manuscript.pdf
ots stamp webpage/v/$TRAVIS_COMMIT/index.html
if [ "$BUILD_PDF" != "false" ]; then
ots stamp webpage/v/$TRAVIS_COMMIT/manuscript.pdf
fi

# Commit message
MESSAGE="\

0 comments on commit 44c5d35

Please sign in to comment.