-
Notifications
You must be signed in to change notification settings - Fork 165
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
pdf version specs #427
Closed
Closed
pdf version specs #427
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b6d9875
changes to generate pdf-version of the specs
Arshitha 30e3aab
included name to contributors file
Arshitha b3ddd2e
Fixed bugs as suggested on the pdf-version issue
Arshitha 877a303
Merge pull request #1 from bids-standard/master
Arshitha 5a5dc3f
Merge branch 'pdf-version' into master
Arshitha 4fefe5b
updated branch with most recent commits from base repo
Arshitha 4a2601c
deleted all files
Arshitha 8aa83e6
added most recent version of files
Arshitha 4794112
new branch with more readable commit history
Arshitha a5667bf
removed remove_cross_internal_links function
Arshitha c00d029
added comments and cleaned up code
Arshitha a3efecf
added readme and cleaned up code
Arshitha e9538f4
reverted modifications to CHANGES.md and fixed file naming to bids-sp…
Arshitha 626f1a4
adding title and version details to the cover page
Arshitha 0ec12cb
Merge remote-tracking branch 'upstream/master'
Arshitha 3476e74
Merge branch 'master' into updated-pdf-version-specs
Arshitha 73caef4
STY: Fixed Markdown Style
Arshitha 07084c7
Changes based on code review
Arshitha 980894f
cleaned up code and final checks with circleci
Arshitha 5074814
resolving merge conflicts in circleci config file
Arshitha fd71fb9
importing changes from 'updated-pdf-version-specs' branch
Arshitha e41e813
column width adjustment
Arshitha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
site/ | ||
site/ | ||
node_modules/ | ||
package-lock.json |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# pdf-version of BIDS specification | ||
|
||
The `pdf_build_src` directory contains the scripts and tex files required to build a pdf document of the BIDS specification from multiple markdown files using the pandoc library. | ||
|
||
Pandoc is command line tool which is also a Haskell library that converts files from one markup format to another. More here: https://pandoc.org/index.html | ||
|
||
## Requirements | ||
|
||
For the pdf build to be successful, the following need to be installed: | ||
|
||
- Python 3.x | ||
- pandoc | ||
- Latest version of LaTeX: By default, Pandoc creates PDFs using LaTeX. Because a full MacTeX installation uses four gigabytes of disk space, pandoc recommends BasicTeX or TinyTeX and using the tlmgr tool to install additional packages as needed. | ||
|
||
Installation instructions for both pandoc and LaTeX: https://pandoc.org/installing.html | ||
|
||
## Building pdf document | ||
|
||
Run the `build_pdf.sh` from the `pdf_build_src` with the command `sh build_pdf.sh` from the command line terminal | ||
|
||
List of warnings are for missing characters like emojis while converting from markdown to pdf. Except for losing those characters in the final document, it doesn't affect the formatting or contents and therefore, can be ignored. | ||
|
||
## Technical Overview | ||
|
||
Pandoc comes with a plethora of options to format the resulting document. For building a pdf from multiple markdowns, a consolidated intermediate tex file is first built, which is then converted to a pdf document. To achieve the desired formatting in the final pdf, additional tex files are used with options offered by pandoc. | ||
|
||
### Formatting files | ||
|
||
`listings_setup.tex` - Listings is a LaTeX package used for typestting programming code in TeX. This file sets up the listings package to suit our needs and is used with the `--listings` option. | ||
|
||
`cover.tex` - BIDS Logo is used as a cover page for the document. `cover.tex` is used with the option `--include-before-body` | ||
|
||
`header.tex` - Header tex file that's updated with the latest version number and date when `build_pdf.sh` is run. Used with the `-H` header option. | ||
|
||
### Scripts | ||
|
||
`process_markdowns.py` - Script that processes markdown files in the `src` directory that are duplicated and modified for the needs of the pdf. | ||
|
||
`pandoc_script.py` - Prepares and runs the final pandoc command through the `build_pdf.sh` script | ||
|
||
`build_pdf.sh` - Shell script that organizes the directory structure and runs the above two python scripts |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Shell script that runs process_markdowns.py and pandoc_script.py in sequence to build the pdf document | ||
|
||
# prepare the copied src directory | ||
python3 process_markdowns.py | ||
|
||
# copy pandoc_script into the temp src_copy directory | ||
cp pandoc_script.py header.tex cover.tex listings_setup.tex src_copy/src | ||
|
||
# run pandoc_script from src_copy directory | ||
cd src_copy/src | ||
python3 pandoc_script.py | ||
mv bids-spec.pdf ../.. | ||
cd ../.. | ||
|
||
# delete the duplicated src directory | ||
rm -rf src_copy |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
% adds the bids logo as the cover page of the pdf | ||
\begin{titlepage} | ||
|
||
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}} % Defines a new command for the horizontal lines, change thickness here | ||
|
||
\center % Center everything on the page | ||
|
||
|
||
|
||
%---------------------------------------------------------------------------------------- | ||
% LOGO SECTION | ||
%---------------------------------------------------------------------------------------- | ||
|
||
\includegraphics[width=0.6\textwidth]{images/BIDS_logo.jpg}\\[1cm] | ||
|
||
%---------------------------------------------------------------------------------------- | ||
% TITLE SECTION | ||
%---------------------------------------------------------------------------------------- | ||
|
||
\HRule \\[0.4cm] | ||
{ \huge \bfseries Brain Imaging Data Structure Specification}\\[0.4cm] % Title of your document | ||
\HRule \\[1.5cm] | ||
|
||
% \textsc{\large v1.2.1}\\[0.5cm]{\large 2019-08-14}\\[2cm] | ||
|
||
% \vfill % Fill the rest of the page with whitespace | ||
\textsc{\large v1.2.1}\\[0.5cm]{\large 2019-08-14}\\[2cm]\vfill\end{titlepage} |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
% header file | ||
\usepackage{fancyhdr} | ||
\pagestyle{fancy} | ||
\fancyhf{} | ||
\chead{Brain Imaging Data Structure v1.2.1 2019-08-14} | ||
\fancyfoot[LE,RO]{\thepage} |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
% Contents of listings-setup.tex | ||
\usepackage{xcolor} | ||
\usepackage{graphicx} | ||
|
||
\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 | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""Use the pandoc library as a final step to build the pdf. | ||
|
||
This is done once the duplicate src directory is processed. | ||
""" | ||
import os | ||
import subprocess | ||
|
||
|
||
def build_pdf(filename): | ||
"""Construct command with required pandoc flags and run using subprocess. | ||
|
||
Parameters | ||
---------- | ||
filename : str | ||
Name of the output file. | ||
|
||
""" | ||
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) | ||
|
||
default_pandoc_cmd = "pandoc " | ||
|
||
# creates string of file paths in the order we'd like them to be appear | ||
# ordering is taken care of by the inherent file naming | ||
files_string = index_page + " " + " ".join(sorted(markdown_list)) | ||
|
||
flags = (" -f markdown_github --include-before-body cover.tex --toc " | ||
"-V documentclass=report --listings -H listings_setup.tex " | ||
"-H header.tex -V linkcolor:blue -V geometry:a4paper " | ||
"-V geometry:margin=2cm --pdf-engine=xelatex -o ") | ||
output_filename = filename | ||
|
||
cmd = default_pandoc_cmd + files_string + flags + output_filename | ||
subprocess.run(cmd.split()) | ||
|
||
|
||
if __name__ == "__main__": | ||
build_pdf('bids-spec.pdf') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering why this line is highlighted as a diff.
In
master
, we should have the exact same line:bids-specification/.circleci/config.yml
Line 60 in 6bd2ad5
... so there shouldn't be a change, actually 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why that's the case. I remember having synced my fork with the latest commits on master, but perhaps I missed something when cherry picking commits from here #400 ?