From 26e457ea413007418683cbee36de0ac98a254c34 Mon Sep 17 00:00:00 2001 From: Francesco Urbani Date: Wed, 24 Mar 2021 16:02:23 +0100 Subject: [PATCH] Added yaml file to instruct pandoc. Added color links inside the PDF. --- createPdfFromReadme.sh | 23 +++++++++++++++++------ pdf_metadata.yaml | 16 ++++++++++++++++ 2 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 pdf_metadata.yaml diff --git a/createPdfFromReadme.sh b/createPdfFromReadme.sh index d23c3a1..255fb61 100755 --- a/createPdfFromReadme.sh +++ b/createPdfFromReadme.sh @@ -6,7 +6,7 @@ # -------------------- Utility Methods -------------------- # Check for binaries function checkEnvironment(){ - type pandoc >/dev/null 2>&1 || { echo "Install 'pandoc' first (e.g. via 'brew install pandoc')." >&2 && exit 1 ; } + type pandoc >/dev/null 2>&1 || { echo "Install 'pandoc' first (e.g. via 'brew install pandoc' or 'apt-get install pandoc')." >&2 && exit 1 ; } type xelatex >/dev/null 2>&1 || { echo "Install 'xelatex' first" >&2 && exit 1 ; } } @@ -20,15 +20,26 @@ function cleanupBeforeStarting(){ # Creates the summary from the generated chapters function convertToLatex(){ cd ./latex - - cp ../*.png . + cp ../*.png . # copy Easy_Rust_sample_image.png in the current folder in order to be found. + + # Step 1: run pandoc on README.md which generates the `.tex` file. + + # Commands used previously (didn't require metadata.yaml). Left here for reference... + # pandoc ../README.md -V geometry:margin=0.7in -V colorlinks=true -V linkcolor=blue -V urlcolor=blue -V toccolor=gray --standalone --from markdown --to latex > easy_rust.tex + # pandoc ../README.md --standalone --from markdown --to latex > easy_rust.tex - pandoc ../README.md -V geometry:margin=0.7in --standalone --from markdown --to latex > easy_rust.tex + # generates `easy_rust.tex` in the current folder using the instructions given inside `../pdf_metadata.yaml`. + pandoc ../README.md ../pdf_metadata.yaml -s -o easy_rust.tex # --toc # The `toc` flag can be added or not depending on personal preferences. + # If added, the `xelatex` command right below needs to be run twice (the first time.) echo "Generated easy_rust.tex file." - xelatex --interaction=nonstopmode easy_rust.tex - echo "Generated PDF file easy_rust.pdf" + # Step 2: run `xelatex` on the `.tex` file to geneate the PDF. + xelatex --interaction=nonstopmode easy_rust.tex + # to generate the TOC you need to run this twice + # xelatex --interaction=nonstopmode easy_rust.tex + + echo "Generated PDF file easy_rust.pdf" cd .. } diff --git a/pdf_metadata.yaml b/pdf_metadata.yaml new file mode 100644 index 0000000..95f571e --- /dev/null +++ b/pdf_metadata.yaml @@ -0,0 +1,16 @@ +--- +title: 'Easy Rust' +author: +- https://github.com/Dhghomon/easy_rust +keywords: [rust, easy-rust] +# abstract: | +# Rust explained using easy English + +geometry: margin=0.7in #left=1cm,right=1cm,top=2cm,bottom=2cm + +colorlinks: true +linkcolor: blue +urlcolor: blue +toccolor: gray + +...