First commit
This commit is contained in:
commit
9e22a6fd88
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.pandoc.pdf
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "filters/pandoc-crossref"]
|
||||
path = filters/pandoc-crossref
|
||||
url = https://github.com/lierdakil/pandoc-crossref
|
11
Makefile
Normal file
11
Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
SOURCES = $(wildcard *.md)
|
||||
OUT = $(SOURCES:.md=.pdf)
|
||||
|
||||
all: $(OUT)
|
||||
|
||||
$(OUT): $(SOURCES)
|
||||
pandoc --smart -t latex $< --filter=filters/pandoc-svg.py --filter=pandoc-crossref -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OUT)
|
||||
find . -name "*.pandoc.pdf" -delete
|
27
README.md
Normal file
27
README.md
Normal file
@ -0,0 +1,27 @@
|
||||
Pandoc boilerplate
|
||||
==================
|
||||
|
||||
Boilerplate to render scientific documents written in Markdown to LaTeX, using
|
||||
Pandoc.
|
||||
|
||||
Includes various Pandoc filters:
|
||||
|
||||
* Automatically convert `SVG` files to `PDF` and rewrite the image link to
|
||||
include them in the document easily.
|
||||
|
||||
* Include [pandoc-crossref](https://github.com/lierdakil/pandoc-crossref) for
|
||||
easy numbering and referencing.
|
||||
|
||||
|
||||
## TODO
|
||||
|
||||
* automatically convertfunction names (cos, sin, exp, log) to their
|
||||
LaTeX equivalent (\cos and so on) when in a mathematical environment,
|
||||
then taking out the useless leading `\`.
|
||||
|
||||
* not having to use \frac{}{} to write fractions, but instead
|
||||
automatically convert simple fractions in math environment to \frac{}{}
|
||||
(for instance convert "(1 / 2)" to "\frac{1}{2}")
|
||||
|
||||
* anything else like this that could help writing more readable LaTeX
|
||||
code :)
|
43
filters/pandoc-svg.py
Normal file
43
filters/pandoc-svg.py
Normal file
@ -0,0 +1,43 @@
|
||||
#! /usr/bin/env python
|
||||
"""
|
||||
Pandoc filter to convert svg files to pdf as suggested at:
|
||||
https://github.com/jgm/pandoc/issues/265#issuecomment-27317316
|
||||
"""
|
||||
|
||||
__author__ = "Jerome Robert"
|
||||
|
||||
import mimetypes
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
from pandocfilters import toJSONFilter, Image
|
||||
|
||||
# TODO add emf export if fmt=="docx" ?
|
||||
fmt_to_option = {
|
||||
"latex": ("--export-pdf", "pdf"),
|
||||
"beamer": ("--export-pdf", "pdf"),
|
||||
# because of IE
|
||||
"html": ("--export-png", "png")
|
||||
}
|
||||
|
||||
|
||||
def svg_to_any(key, value, fmt, meta):
|
||||
if key == 'Image':
|
||||
alt, [src, title] = value[1], value[-1]
|
||||
mimet, _ = mimetypes.guess_type(src)
|
||||
option = fmt_to_option.get(fmt)
|
||||
if mimet == 'image/svg+xml' and option:
|
||||
base_name, _ = os.path.splitext(src)
|
||||
eps_name = base_name + "." + "pandoc." + option[1]
|
||||
try:
|
||||
mtime = os.path.getmtime(eps_name)
|
||||
except OSError:
|
||||
mtime = -1
|
||||
if mtime < os.path.getmtime(src):
|
||||
cmd_line = ['inkscape', option[0], eps_name, src]
|
||||
sys.stderr.write("Running %s\n" % " ".join(cmd_line))
|
||||
subprocess.call(cmd_line, stdout=sys.stderr.fileno())
|
||||
return Image(['', [], []], alt, [eps_name, title])
|
||||
|
||||
if __name__ == "__main__":
|
||||
toJSONFilter(svg_to_any)
|
18
notes.md
Normal file
18
notes.md
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
# Metadata
|
||||
title: %title%
|
||||
author: Lucas Verney
|
||||
date: \today
|
||||
# LaTeX headers
|
||||
header-includes:
|
||||
- \usepackage{dsfont}
|
||||
- \usepackage{mathtools}
|
||||
- \renewcommand{\arraystretch}{1.5}
|
||||
# Pandoc-crossref options
|
||||
cref: True
|
||||
chapters: True
|
||||
---
|
||||
\tableofcontents
|
||||
|
||||
\pagebreak
|
||||
|
Loading…
Reference in New Issue
Block a user