From 05c53870a5d0cd75fac97fe5409085b3a7f32c6f Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 7 May 2021 17:19:45 +0200 Subject: [PATCH 1/6] ignore temporary pdf build output --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 192fbbcf8a..363a7b2c03 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ site/ venvs pdf_build_src/bids-spec.pdf +pdf_build_src/src_copy # JS/NPM package-lock.json From 8ba9a5a3470080ff0897fdeb754be993002e8064 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 7 May 2021 17:20:03 +0200 Subject: [PATCH 2/6] remove superfluous brackets in script --- pdf_build_src/build_pdf.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/pdf_build_src/build_pdf.sh b/pdf_build_src/build_pdf.sh index a6b33da81c..fb5e905169 100755 --- a/pdf_build_src/build_pdf.sh +++ b/pdf_build_src/build_pdf.sh @@ -10,11 +10,9 @@ python3 process_markdowns.py cp pandoc_script.py header.tex cover.tex header_setup.tex src_copy/src # run pandoc_script from src_copy directory -( cd src_copy/src python3 pandoc_script.py mv bids-spec.pdf ../.. -) # delete the duplicated src directory rm -rf src_copy From 08b38932ebd26d2130e3ba1a98006764257b4b7a Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 7 May 2021 17:21:01 +0200 Subject: [PATCH 3/6] add pandoc metadata.yml file for easier settings --- pdf_build_src/README.md | 2 ++ pdf_build_src/metadata.yml | 8 ++++++++ pdf_build_src/pandoc_script.py | 8 ++------ 3 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 pdf_build_src/metadata.yml diff --git a/pdf_build_src/README.md b/pdf_build_src/README.md index 7a4740ee7f..be74d31ff1 100644 --- a/pdf_build_src/README.md +++ b/pdf_build_src/README.md @@ -32,6 +32,8 @@ additional tex files are used with options offered by pandoc. ### Formatting files +- `metadata.yml` - Contains formatting options for the PDF. + - `header_setup.tex` - This file sets up the packages to suit our needs. - `cover.tex` - BIDS Logo is used as a cover page for the document. `cover.tex` is used with the option `--include-before-body` diff --git a/pdf_build_src/metadata.yml b/pdf_build_src/metadata.yml new file mode 100644 index 0000000000..3d8feb07e4 --- /dev/null +++ b/pdf_build_src/metadata.yml @@ -0,0 +1,8 @@ +--- +documentclass: report +classoption: table +colorlinks: true +linkcolor: blue +toc: true +listings: true +--- diff --git a/pdf_build_src/pandoc_script.py b/pdf_build_src/pandoc_script.py index a6ff98aed2..9a86bdb8a0 100644 --- a/pdf_build_src/pandoc_script.py +++ b/pdf_build_src/pandoc_script.py @@ -28,14 +28,10 @@ def build_pdf(filename): # Prepare the command options cmd = [ 'pandoc', - '--from=markdown_github', + '--from=markdown_github+yaml_metadata_block', '--include-before-body=./cover.tex', - '--toc', - '--listings', '--include-in-header=./header.tex', '--include-in-header=./header_setup.tex', - '-V documentclass=report', - '-V linkcolor:blue', '--pdf-engine=xelatex', '--output={}'.format(filename), ] @@ -56,7 +52,7 @@ def build_pdf(filename): # Add input files to command # The filenames in `markdown_list` will ensure correct order when sorted cmd += [str(root / index_page)] - cmd += [str(root / i) for i in sorted(markdown_list)] + cmd += [str(root / i) for i in ["../../metadata.yml"] + sorted(markdown_list)] # print and run print('running: \n\n' + '\n'.join(cmd)) From b03d1ae008c3b35c9cbf7b9e6f0da336e0b89919 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 7 May 2021 17:30:27 +0200 Subject: [PATCH 4/6] color every other row in tables --- pdf_build_src/header_setup.tex | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pdf_build_src/header_setup.tex b/pdf_build_src/header_setup.tex index 51d4a6475c..ec9c558ad4 100644 --- a/pdf_build_src/header_setup.tex +++ b/pdf_build_src/header_setup.tex @@ -1,6 +1,3 @@ -\usepackage{xcolor} -\usepackage{graphicx} - \usepackage{fontspec} \setmainfont{Symbola} @@ -27,3 +24,5 @@ } \usepackage[a4paper,margin=0.75in,landscape]{geometry} + +\rowcolors{2}{gray!10}{white} From 714a1094387f7158457e853c44fbef68e943e5c3 Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 7 May 2021 20:56:05 +0200 Subject: [PATCH 5/6] fix: exclude some MD files from pdf --- pdf_build_src/pandoc_script.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pdf_build_src/pandoc_script.py b/pdf_build_src/pandoc_script.py index 9a86bdb8a0..22c1e79d74 100644 --- a/pdf_build_src/pandoc_script.py +++ b/pdf_build_src/pandoc_script.py @@ -16,14 +16,19 @@ def build_pdf(filename): Name of the output file. """ + # Files that are not supposed to be built into the PDF + EXCLUDE = ["./index.md", "./schema/README.md", "./pregh-changes.md"] + # Get all input files markdown_list = [] for root, dirs, files in os.walk('.'): for file in files: - if file.endswith(".md") and file != 'index.md': - markdown_list.append(os.path.join(root, file)) - elif file == 'index.md': - index_page = os.path.join(root, file) + fpath = os.path.join(root, file) + if fpath.endswith(".md") and fpath not in EXCLUDE: + markdown_list.append(fpath) + elif fpath.endswith('index.md'): + # Special role for index.md + index_page = fpath # Prepare the command options cmd = [ From cf4bba5ab961f5847b6aac89152f83967e0df26c Mon Sep 17 00:00:00 2001 From: Stefan Appelhoff Date: Fri, 7 May 2021 21:35:41 +0200 Subject: [PATCH 6/6] remove unused listings settings PDF --- pdf_build_src/header_setup.tex | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/pdf_build_src/header_setup.tex b/pdf_build_src/header_setup.tex index ec9c558ad4..8835811734 100644 --- a/pdf_build_src/header_setup.tex +++ b/pdf_build_src/header_setup.tex @@ -1,28 +1,6 @@ \usepackage{fontspec} \setmainfont{Symbola} -\lstset{ - basicstyle=\ttfamily, - numbers=left, - keywordstyle=\color[rgb]{0.13,0.29,0.53}\bfseries, - stringstyle=\color[rgb]{0.31,0.60,0.02}, - commentstyle=\color[rgb]{0.56,0.35,0.01}\itshape, - numberstyle=\footnotesize, - stepnumber=1, - numbersep=5pt, - backgroundcolor=\color[RGB]{248,248,248}, - showspaces=false, - showstringspaces=false, - showtabs=false, - tabsize=2, - captionpos=b, - breaklines=true, - breakautoindent=true, - escapeinside={\%*}{*)}, - linewidth=\textwidth, - basewidth=0.5em -} - \usepackage[a4paper,margin=0.75in,landscape]{geometry} -\rowcolors{2}{gray!10}{white} +\rowcolors{1}{}{gray!10}