Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishektiwari committed Apr 2, 2024
0 parents commit fa2d5e5
Show file tree
Hide file tree
Showing 14 changed files with 2,308 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Build

on:
push:
branches:
- main

jobs:
convert_via_pandoc:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed files
id: changed-files-yaml
uses: tj-actions/changed-files@v42
with:
files_yaml: |
paper:
- paper/**
- paper/images/**
- csl/**
- data/templates/**
- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=v$calculatedSha" >> $GITHUB_ENV
- name: Set env for time now
run: echo "NOW=v$(date +'%Y%m%d')" >> $GITHUB_ENV

- name: Run step if paper file(s) change
if: steps.changed-files-yaml.outputs.paper_any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files-yaml.outputs.paper_all_changed_files }}
run: |
echo "One or more files in the paper folder has changed."
echo "List all the files that have changed: $ALL_CHANGED_FILES"
- name: Install pandoc if paper file(s) change
if: steps.changed-files-yaml.outputs.paper_any_changed == 'true'
run: sudo apt-get update && curl -sLO https://github.com/jgm/pandoc/releases/download/3.1.12.1/pandoc-3.1.12.1-1-amd64.deb && sudo dpkg -i pandoc-3.1.12.1-1-amd64.deb && pandoc -v

- name: Install graphviz and panflute if paper file(s) change
if: steps.changed-files-yaml.outputs.paper_any_changed == 'true'
run: sudo apt-get install graphviz libgraphviz-dev -y && pip install panflute graphviz

- name: Install pygraphviz if paper file(s) change
if: steps.changed-files-yaml.outputs.paper_any_changed == 'true'
run: pip install pygraphviz && pip list

- name: Install texlive if paper file(s) change
if: steps.changed-files-yaml.outputs.paper_any_changed == 'true'
run: sudo apt-get install texlive-full -y

- name: Run paper pdf build if paper file(s) change
if: steps.changed-files-yaml.outputs.paper_any_changed == 'true'
run: cd paper && pandoc --bibliography article.bibtex --citeproc article.md -o article.pdf --from markdown --metadata-file=metadata.yaml --data-dir=../data --template eisvogel.tex --listings -F panflute && pwd && ls -la

- name: Upload article pdf if paper file(s) change
if: steps.changed-files-yaml.outputs.paper_any_changed == 'true'
uses: svenstaro/upload-release-action@v2
with:
file: /home/runner/work/paper/paper/paper/article.pdf
overwrite: true
tag: ${{ env.NOW }}
body: ${{ github.event.head_commit.message }}
165 changes: 165 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
*.pdf
.DS_Store
graphviz-images/*
paper/graphviz-images/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

MIT License

Copyright (c) 2024 Abhishek Tiwari

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Paper Template
Template repository to write academic research paper using markdown and generate PDF using Pandoc.

1. Create a new Github repository using this template by clicking `Use this template``Create a new repository`.

2. After creating a new repository, enable `Workflow permissions` to `Read and write permissions` for your Github repository by going to `Settings``Actions``General`. This allows Github Actions to build PDF output and upload it to release.

## Steps for local build

- Update paper metadata `metadata.yaml`
- Update paper content `article.md`
- Update the citation `article.bibtex` and cite them in `article.md`. See [Pandoc guide on citation ](https://pandoc.org/chunkedhtml-demo/8.20-citation-syntax.html).
- Add images to `images` folder and include them in `article.md` as markdown iamges. See [Pandoc guide on images](https://pandoc.org/chunkedhtml-demo/8.17-images.html).
- Run the build `bash build.sh` to generate `article.pdf`

## Steps for Action build

- Commit your paper changes and push.
- If you have changed the following folders Github Action will perform `article.pdf` build. Due to large size of `texlive-full`, currently build takes anywhere between 6-8 minutes.
- `paper/**`
- `paper/images/**`
- `csl/**`
- `data/templates/**`
- On successful build `article.pdf` will be uploaded to `Releases` section of your Github repository.


# Prerequisite
On Mac Install `texlive`, `pandoc` using `brew`,

```
brew install pandoc texlive graphviz
```

Install only required `texlive` packages,
```
sudo tlmgr install beamerarticle pgfpages amsmath amssymb setspace inputenc mathspec unicode-math lmodern xeCJK upquote parskip fancyvrb xcolor hang flushmargin bottom multiple adjustbox graphicx listings etoolbox fvextra multirow longtable booktabs array caption headsepline footsepline titling footnotebackref sourcesanspro mdframed csquotes pagecolor afterpage tikz hyperref bookmark biblatex selnolig natbib babel calc subcaption soul luacolor svg float ccicons datetime2 algorithm2e ifoddpage relsize neuralnetwork pgf
```

Alternatively, install `texlive-full`,

```
brew install pandoc texlive-full
```

Install Python packages using `pip` to run `panflute` filters.

```
pip install panflute graphviz
python3 -m pip install -U --no-cache-dir \
--config-settings="--global-option=build_ext" \
--config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
--config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
pygraphviz
```
Empty file added backgrounds/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd paper
pandoc --bibliography article.bibtex --citeproc article.md -o article.pdf --from markdown --metadata-file=metadata.yaml --data-dir=../data --template eisvogel.tex --listings -F panflute
Loading

0 comments on commit fa2d5e5

Please sign in to comment.