-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix up mkpdf.sh This change fixes mkpdf.sh to take the dependency on build.sh inside the Docker container instead of doing the fixups itself. It simplifies the script down to: 1. Create and mount a temp directory for simplified file I/O to the Docker container 2. Use docker run but with a customized entrypoint that also copies files to the current directory and back to the working directory 3. Check for errors * Add some quality-of-life changes to the TCG fork of Eisvogel 1. Increase the limit for list nesting depth from 5 to 9 2. Enable more than one line of error output, for debugging * Remove citations, add table_captions This change adds some improved complex TCG doc support to build.sh. The extension `grid_tables` is added, which is the only way to have a table with cells that span multiple columns or rows without writing your tables in raw HTML. The extension `citations` is removed: it gets messed up by TCG documents with "@" symbols, and TCG typically handles its own references section manually (e.g., in a section called Normative References) A trivial typo is fixed: "resouredir" -> "resourcedir" * Add mathtools to the latex plugins * move enumitem settings to just before the document * try moving the enumitem settings to near the header-includes * remove math-mode $'s around labels * add mathtools, add grid table sample * move usepackage mathtools * render all samples
- Loading branch information
1 parent
1650632
commit 0c33b2d
Showing
6 changed files
with
54 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ print_usage() { | |
echo "$(basename "${0}") [options] [input-file]" | ||
echo | ||
echo "Arguments:" | ||
echo " This script takes a single markdown file input for rendering to docx/pdf/LaTex." | ||
echo " This script takes a single markdown file input for rendering to docx/pdf/LaTeX." | ||
echo | ||
echo "Options:" | ||
echo | ||
|
@@ -34,14 +34,14 @@ print_usage() { | |
echo | ||
echo "Miscellaneous" | ||
echo " --puppeteer: enable outputing of .puppeteer.json in current directory. This is needed for running in sandboxes eg docker containers." | ||
echo " --resouredir=dir: Set the resource directory, defaults to root for pandoc containers" | ||
echo " --resourcedir=dir: Set the resource directory, defaults to root for pandoc containers" | ||
echo " --notmp: Do not use a tempory directory for processing steps, instead create a directory called \"build\" in CWD" | ||
echo " --gitversion: Use git describe to generate document version and revision metadata." | ||
echo " --gitstatus: Use git describe to generate document version and revision metadata. Implies --gitversion" | ||
} | ||
|
||
|
||
if ! options=$(getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,pdf:,latex:,docx:,resouredir: --options="" -- "$@"); then | ||
if ! options=$(getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,pdf:,latex:,docx:,resourcedir: --options="" -- "$@"); then | ||
echo "Incorrect options provided" | ||
print_usage | ||
exit 1 | ||
|
@@ -79,7 +79,7 @@ while true; do | |
pdf_output="${2}" | ||
shift 2 | ||
;; | ||
--resouredir) | ||
--resourcedir) | ||
resource_dir="${2}" | ||
shift 2 | ||
;; | ||
|
@@ -259,7 +259,7 @@ export MERMAID_FILTER_FORMAT="pdf" | |
if [ -n "${pdf_output}" ]; then | ||
echo "Generating PDF Output" | ||
pandoc \ | ||
--citeproc \ | ||
--trace \ | ||
--embed-resources \ | ||
--standalone \ | ||
--template=eisvogel.latex \ | ||
|
@@ -279,7 +279,7 @@ if [ -n "${pdf_output}" ]; then | |
--metadata=titlepage-rule-height:0 \ | ||
--metadata=colorlinks:true \ | ||
--metadata=contact:[email protected] \ | ||
--from=markdown+implicit_figures+table_captions+citations \ | ||
--from=markdown+implicit_figures+grid_tables+table_captions-citations \ | ||
${extra_pandoc_options} \ | ||
--to=pdf \ | ||
"${build_dir}/${input_file}.3" \ | ||
|
@@ -291,7 +291,6 @@ fi | |
if [ -n "${latex_output}" ]; then | ||
echo "Generating LaTeX Output" | ||
pandoc \ | ||
--citeproc \ | ||
--embed-resources \ | ||
--standalone \ | ||
--template=eisvogel.latex \ | ||
|
@@ -311,7 +310,7 @@ if [ -n "${latex_output}" ]; then | |
--metadata=titlepage-rule-height:0 \ | ||
--metadata=colorlinks:true \ | ||
--metadata=contact:[email protected] \ | ||
--from=markdown+implicit_figures+table_captions+citations \ | ||
--from=markdown+implicit_figures+grid_tables+table_captions-citations \ | ||
${extra_pandoc_options} \ | ||
--to=latex \ | ||
"${build_dir}/${input_file}.3" \ | ||
|
@@ -323,15 +322,14 @@ fi | |
if [ -n "${docx_output}" ]; then | ||
echo "Generating DOCX Output" | ||
pandoc \ | ||
--citeproc \ | ||
--embed-resources \ | ||
--standalone \ | ||
--filter=/resources/filters/info.py \ | ||
--filter=mermaid-filter \ | ||
--filter=pandoc-crossref \ | ||
--resource-path=.:/resources \ | ||
--data-dir=/resources \ | ||
--from=markdown+implicit_figures+table_captions+citations \ | ||
--from=markdown+implicit_figures+grid_tables+table_captions-citations \ | ||
--reference-doc=/resources/templates/tcg_template.docx \ | ||
${extra_pandoc_options} \ | ||
--to=docx \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,54 +13,19 @@ if [[ ! -f "$MD" ]]; then | |
fi | ||
|
||
cp $MD $WD/spec.md | ||
MD=$WD/spec.md | ||
DOCKER_MD=$DOCKER_WD/spec.md | ||
|
||
# \newpage is rendered as the string "\newpage" in GitHub markdown. | ||
# Transform horizontal rules into \newpages. | ||
# Exception: the YAML front matter of the document, so undo the instance on the first line. | ||
sed -i 's/^---$/\\newpage/g;1s/\\newpage/---/g' $MD | ||
|
||
# Transform sections before the table of contents into addsec, which does not number them. | ||
# While we're doing this, transform the case to all-caps. | ||
sed -i '0,/\\tableofcontents/s/^# \(.*\)/\\addsec\{\U\1\}/g' $MD | ||
|
||
# Get data | ||
DATE=$(grep "date:" $MD | head -n 1 | cut -d ' ' -f 2) | ||
YEAR=$(date --date=$DATE +%Y) | ||
DATE_ENGLISH=$(date --date=$DATE "+%B %-d, %Y") | ||
|
||
OUT="${DOCKER_WD}/tcgspec.pdf" | ||
|
||
# Make PDF | ||
PANDOC_OPTS="--embed-resources \ | ||
--standalone \ | ||
--template=/resources/template/eisvogel.latex \ | ||
--filter=mermaid-filter \ | ||
--filter=pandoc-crossref \ | ||
--resource-path=.:/resources \ | ||
--data-dir=/resources \ | ||
--top-level-division=section \ | ||
--variable=block-headings \ | ||
--variable=numbersections \ | ||
--variable=table-use-row-colors \ | ||
--metadata=date-english:\"${DATE_ENGLISH}\" \ | ||
--metadata=year:"${YEAR}" \ | ||
--metadata=titlepage:true \ | ||
--metadata=titlepage-background:/resources/img/greentop.png \ | ||
--metadata=logo:/resources/img/tcg.png \ | ||
--metadata=titlepage-rule-height:0 \ | ||
--metadata=colorlinks:true \ | ||
--metadata=contact:[email protected] \ | ||
--from=markdown+implicit_figures+table_captions \ | ||
--to=pdf \ | ||
--output=${OUT}" | ||
OUT="${DOCKER_WD}/output.pdf" | ||
|
||
SCRIPT_OPTS="--pdf=output.pdf spec.md" | ||
DOCKER_OPTS="-v $WD:$DOCKER_WD" | ||
DOCKER_COMMAND="cp $DOCKER_MD .; /usr/bin/build.sh $SCRIPT_OPTS; cp ./output.* $DOCKER_WD" | ||
IMAGE_NAME="ghcr.io/trustedcomputinggroup/pandoc" | ||
|
||
# Quotes around DATE_ENGLISH get messed up during expansion. Instead, | ||
# quotes are added menually above and eval is used to execute the command. | ||
eval "docker run $DOCKER_OPTS $IMAGE_NAME $DOCKER_MD $PANDOC_OPTS" | ||
eval "docker run $DOCKER_OPTS --entrypoint /bin/sh $IMAGE_NAME -c '$DOCKER_COMMAND'" | ||
|
||
echo "Generated spec at $OUT" | ||
if [ $? -eq 0 ]; then | ||
echo "Generated spec at $OUT" | ||
else | ||
echo "Failed to generate spec" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters