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

Added Markdown support via pandoc #45

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ PLATFORM := $(shell uname)

all: build

md:
$(MAKE) -C ./markdown
$(MAKE) build

setup:
@echo "Current Platform: $(PLATFORM)"
@echo "Current Distribution: $(DIST)"
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ you think you've already solved the problem in the LaTeX sources, maybe try a
`cleanall` before insisting. Sometimes the underlying build programs (namely
`latexmk`) get stuck in inconsistent temporary files.


Compile it from markdown using pandoc:

```
make md
```

`md` will compile all the markdown files inside `/markdown/content/`, merged alphabetically, into a two latex files that **will overwrite** `cover.tex` and `matter.tex`.
After this, the `build` target will run.
For more information please read `/markdown/README.md`

## How to use the template

This is all great, but how can this repository be used as a starting point for
Expand Down
5 changes: 5 additions & 0 deletions markdown/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.venv/
venv/
filters/pandoc-minted/
matter.tex
cover.tex
52 changes: 52 additions & 0 deletions markdown/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#SHELL := /bin/bash

all:
. .venv/bin/activate && \
pandoc \
-f markdown /dev/null \
-o ../cover.tex \
--template=./templates/cover_template.tex \
--metadata-file=metadata.yaml && \
pandoc \
--filter ./filters/acronyms.py \
--filter ./filters/citations.py \
--filter ./filters/pandoc-minted/pandoc-minted.py \
--template=./templates/matter_template.tex \
-o ../matter.tex \
--top-level-division=chapter \
--metadata-file=metadata.yaml \
./content/*.md && \
pandoc \
--filter ./filters/acronyms.py \
--filter ./filters/citations.py \
--filter ./filters/pandoc-minted/pandoc-minted.py \
-o ../appendix.tex \
--top-level-division=chapter \
--metadata-file=metadata.yaml \
./appendixes/*.md

install:
python3 -m venv .venv
. .venv/bin/activate && \
pip3 install -r requirements.txt

cd filters && \
git clone https://github.com/nick-ulle/pandoc-minted.git

test:
. .venv/bin/activate && \
pandoc \
-f markdown /dev/null \
-o ../cover.tex \
--template=./templates/cover_template.tex \
--metadata-file=metadata.yaml && \
pandoc \
--filter ./filters/acronyms.py \
--filter ./filters/citations.py \
--filter ./filters/pandoc-minted/pandoc-minted.py \
--template=./templates/matter_template.tex \
-o ../matter.tex \
--top-level-division=chapter \
--metadata-file=metadata.yaml \
./demo.md

99 changes: 99 additions & 0 deletions markdown/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Writing Your Thesis in Markdown

It is possible to use the UA thesis template with markdown + pandoc.

## File Structure

The `markdown` directory is structured as follows:

```
.
├── content
│   └── thesis.md
├── demo.md
├── filters
│   ├── acronyms.py
│   └── pandoc-minted
│   ├── LICENSE
│   ├── pandoc-minted.py
│   └── README.md
├── Makefile
├── metadata.yaml
├── README.md
├── requirements.txt
└── templates
├── cover_template.tex
└── matter_template.tex
```

`content` is where all the markdown files for the thesis will reside.

`thesis.md` is where one should write their thesis, or one of its parts.

`demo.md` is a demo file showcasing pandoc's markdown functionality.

`filters` contains the filters in use, see [What is Installed](#what-is-installed) for more details.

`Makefile` contains a couple targets that compile the files in various scenarios. See [Cmake Targets](#cmake-targets) for more details.

`metadata.yaml` is where the template is configured.

`README.md` is this file, containing an overview of how to use pandoc and markdown to write a thesis.

`requirements.txt` contains the python dependencies needed for the filters. See [What is Installed](#what-is-installed) for more details.

`templates` contains modified versions of `matter.tex` and `cover.tex` that allow for customization via yaml configuration.

## Cmake targets

`all` compiles all the markdown files in `content`. To actually compile the thesis please also run `make` in the repository's root directory (or run `make md` from there to do it all in one step).

`install` installs all dependencies. See [Installation](#installation) for more details.

`test` compiles `demo.md`, using it in the thesis template. To actually compile the thesis please also run `make` in the repository's root directory.

## Installation

In order for the compilation to work, some filters and python dependencies have to be installed.

Please run `make install` inside this directory to create a python virtual environment in this directory under `.venv`

It will be automatically used when compiling the markdown into latex.

### What is installed

Pandoc filters:

- [pandoc-minted](https://github.com/nick-ulle/pandoc-minted), to use `minted` for typesetting, as the template uses.

Python dependencies:

- [pandocfilters](https://pypi.org/project/pandocfilters/), to be able to make python pandoc filters
- [pyyaml](https://pypi.org/project/PyYAML/), to be able to read yaml data for the metadata

## Usage

In order to compile the thesis from markdown into pdf, use `make md` in the repository root.

If you only need to compile the markdown into the latex files, use `make` inside this directory.

Citations are made with inline latex and bibliography is stored in the `/bib` directory

Acronyms are managed by the `acronym` package and wrapped by the `filters.py` filter. In the metadata, place all acronyms under the `acronyms` field in the following format:

```yaml
# Example
- id: <the string to replace in the text>
short: <the short form to replace the string with>
long: <the long form to be used in the first occurence>
```

Example:

```yaml
# Every time `ai` is written in the document, replace it with `AI`, or `Artificial Intelligence (AI)` in the first occurence
acronyms:
- id: ai
short: AI
long: Artificial Intelligence
```
Empty file added markdown/appendixes/appendix.md
Empty file.
Empty file added markdown/content/thesis.md
Empty file.
Loading