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 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/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 diff --git a/pdf_build_src/header_setup.tex b/pdf_build_src/header_setup.tex index 51d4a6475c..8835811734 100644 --- a/pdf_build_src/header_setup.tex +++ b/pdf_build_src/header_setup.tex @@ -1,29 +1,6 @@ -\usepackage{xcolor} -\usepackage{graphicx} - \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{1}{}{gray!10} 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..22c1e79d74 100644 --- a/pdf_build_src/pandoc_script.py +++ b/pdf_build_src/pandoc_script.py @@ -16,26 +16,27 @@ 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 = [ '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 +57,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))