Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INFRA] In PDF, color every other row in table in light gray fill #794

Merged
merged 6 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ site/
venvs

pdf_build_src/bids-spec.pdf
pdf_build_src/src_copy

# JS/NPM
package-lock.json
Expand Down
2 changes: 2 additions & 0 deletions pdf_build_src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 0 additions & 2 deletions pdf_build_src/build_pdf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
27 changes: 2 additions & 25 deletions pdf_build_src/header_setup.tex
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 8 additions & 0 deletions pdf_build_src/metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
documentclass: report
classoption: table
colorlinks: true
linkcolor: blue
toc: true
listings: true
---
21 changes: 11 additions & 10 deletions pdf_build_src/pandoc_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]
Expand All @@ -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))
Expand Down