File: pandoc.mk

package info (click to toggle)
wajig 4.1.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 408 kB
  • sloc: python: 2,553; makefile: 146; sh: 117
file content (134 lines) | stat: -rw-r--r-- 3,069 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
########################################################################
#
# Makefile template for Document Format Conversion - pandoc
#
# Copyright 2018 (c) Graham.Williams@togaware.com
#
# License: Creative Commons Attribution-ShareAlike 4.0 International.
#
########################################################################

########################################################################
# GLOBAL VARIABLES
#
# I think the geometry for LaTeX should be a4 rather than a4paper to
# work with newer LaTeX. Should only need lang which pandoc should
# underneath also set babel-lang but that does not seem to be working
# 20171230 (reference man page).

PANDOC_PDF_OPTIONS=-V urlcolor=cyan -V geometry=a4paper -V lang=en-AU -V babel-lang=british --number-sections

PANDOC_TEX_OPTIONS=$(PANDOC_PDF_OPTIONS) --standalone --template eisvogel --listings

PANDOC_CSS=pandoc.css

PANDOC_HTML_OPTIONS=--standalone --self-contained
ifneq ("$(wildcard ../$(PANDOC_CSS))","")
  PANDOC_HTML_OPTIONS := $(PANDOC_HTML_OPTIONS) --include-in-header=../$(PANDOC_CSS)
endif
ifneq ("$(wildcard $(PANDOC_CSS))","")
  PANDOC_HTML_OPTIONS := $(PANDOC_HTML_OPTIONS) --include-in-header=$(PANDOC_CSS)
endif

########################################################################
# HELP

define PANDOC_HELP
PanDoc:

  Input:
    org   Emacs org mode (the original).
    rst   Attempt to improve markdown.
    md    Mardown documents.

  Output:
    txt   Plain text file with duplicate empty lines removed.
    md	  Markdown.
    docx  Microsoft Word.
    html
    tex	  LaTeX.
    pdf

  Example:

    $ make README.pdf  # Generate .pdf from .org.

  Default conversion options:

    PDF:  $(PANDOC_PDF_OPTIONS)
    TEX:  $(PANDOC_TEX_OPTIONS)
    HTML: $(PANDOC_HTML_OPTIONS)

endef
export PANDOC_HELP

help::
	@echo "$$PANDOC_HELP"

########################################################################
# RULES

%.txt: %.rst
	pandoc -t plain $< | perl -00pe0 > $@

%.txt: %.md
	pandoc -t plain $< | perl -00pe0 > $@

%.md: %.rst
	pandoc $< -o $@

%.docx: %.org
	pandoc $(PANDOC_PDF_OPTIONS) $< -o $@

%.html: %.org
	pandoc -o $@ $<

%.html: %.rst
	pandoc $(PANDOC_HTML_OPTIONS) -o $@ $<
ifneq ("$(HTML_MSG)","")
	sed -i -e "s|</body>|$(HTML_MSG)\n</body>|g" $@
endif

%.html: %.md
	pandoc $(PANDOC_HTML_OPTIONS) -o $@ $<

%.md: %.rst
	pandoc $< -o $@

%.md: %.ipynb
	jupyter nbconvert --to markdown $< --stdout > $@

#	notedown $< --to markdown --strip > $@

%.R: %.ipynb
	jupyter-nbconvert --to python $< --stdout > $@

%.py: %.ipynb
	jupyter-nbconvert --to python $< --stdout > $@

%.txt: %.rst
	pandoc -t plain $< | perl -00pe0 > $@

%.txt: %.md
	pandoc -t plain $< | perl -00pe0 $@

%.tex: %.org
	pandoc $(PANDOC_TEX_OPTIONS) $< -o $@

%.tex: %.md
	pandoc $(PANDOC_TEX_OPTIONS) $< -o $@

%.tex: %.rst
	pandoc $(PANDOC_TEX_OPTIONS) $< -o $@

%.pdf: %.org
	pandoc $(PANDOC_PDF_OPTIONS) $< -o $@

%.pdf: %.rst
	pandoc $(PANDOC_PDF_OPTIONS) $< -o $@

%.pdf: %.md
	pandoc $(PANDOC_TEX_OPTIONS) $< -o $@

%.pdf: %.Rmd
	Rscript -e "rmarkdown::render('$^', 'pdf_document')"