new file: pixi.toml
[GalaxyCodeBases.git] / etc / pandoc / Makefile
blob877cd923e96dae702610783686b0b9dcdcd06a6a
1 # Put this Makefile in your project directory---i.e., the directory containing
2 # the paper you are writing. You can use it to create .html, .docx, and .pdf
3 # output files (complete with bibliography, if present) from your Markdown
4 # file.
6 # Additional notes:
7 # * Change the paths at the top of the file as needed.
9 # * Using `make` without arguments will generate html, tex, pdf, docx,
10 # and odt output files from all of the files with the designated
11 # markdown extension. The default is `.md` but you can change this.
13 # * You can specify an output format with `make tex`, `make pdf`,
14 # `make html`, `make odt`, or `make docx`
16 # * Running `make clean` will only remove all, .html, .pdf, .odt,
17 # and .docx files in your working directory **that have the same name
18 # as your Markdown files**. Other files with these extensions will be safe.
20 # * If wanted, remove the automatic call to `clean` to rely on make's
21 # timestamp checking. However, if you do this, you'll need to add all the
22 # document's images, etc. as dependencies, which means it might be easier
23 # to just clean and delete everything every time you rebuild.
26 # ----------------------
27 # Modifiable variables
28 # ----------------------
29 # Markdown extension (e.g. md, markdown, mdown).
30 MEXT = md
32 # Optional folder for manuscript
33 MS_DIR = .
35 # Location of Pandoc support files.
36 PREFIX = .
38 # Word and HTML can choke on PDF images, so those targets use a helper script
39 # named replace_pdfs to replace all references to PDFs with PNGs and convert
40 # existing PDFs to PNG using sips. However, there are times when it's better to
41 # *not* convert to PNG on the fly, like when using high resolution PNGs exprted
42 # from R with ggsave+Cairo. To disable on-the-fly conversion and supply your
43 # own PNGs, uncomment PNG_CONVERT below. The script will still replace
44 # references to PDFs with PNGs, but will not convert the PDFs
45 PNG_CONVERT = --no-convert
47 # To add version control footer support in PDFs:
48 # 1. Run vcinit in the directory
49 # 2. Place `./vc` at the front of the formula
50 # 3. Add `-V vc` to the pandoc command
51 # 4. Change pagestyle to athgit instead of ath
54 #--------------------
55 # Color definitions
56 #--------------------
57 NO_COLOR = \x1b[0m
58 BOLD_COLOR = \x1b[37;01m
59 OK_COLOR = \x1b[32;01m
60 WARN_COLOR = \x1b[33;01m
61 ERROR_COLOR = \x1b[31;01m
64 # --------------------
65 # Target definitions
66 # --------------------
67 # All markdown files in the working directory
68 SRC = $(wildcard $(MS_DIR)/*.$(MEXT))
69 BASE = $(basename $(SRC))
71 ifeq ($(MS_DIR), .)
72 MS_DIR_FOR_TEX =
73 else
74 MS_DIR_FOR_TEX = "$(MS_DIR)/"
75 endif
77 # Targets
78 PDF=$(SRC:.md=.pdf)
79 HTML=$(SRC:.md=.html)
80 DOCX=$(SRC:.md=.docx)
82 all: clean $(HTML) $(DOCX) $(PDF)
84 pdf: clean $(PDF)
85 html: clean $(HTML)
86 docx: clean $(DOCX)
88 FORMAT = markdown+simple_tables+table_captions+yaml_metadata_block+implicit_figures+link_attributes
89 PANDOC:=$(shell type -P pandoc || type -P /share/FGI2016/brew/bin/pandoc || echo pandoc)
91 %.html: %.md
92 @echo "$(WARN_COLOR)Converting Markdown to HTML using standard template...$(NO_COLOR)"
93 $(PANDOC) -r $(FORMAT) -w html \
94 --default-image-extension=png \
95 --template=$(PREFIX)/templates/html5.template \
96 --css=$(PREFIX)/styles/kultiad-serif.css \
97 -s --toc \
98 -o $@ $<
99 @echo "$(OK_COLOR)All done!$(NO_COLOR)"
101 %.pdf: %.md
102 @echo "$(WARN_COLOR)Converting Markdown to PDF using hikma-article template...$(NO_COLOR)"
103 $(PANDOC) -r $(FORMAT) -w pdf -s -S \
104 --default-image-extension=pdf \
105 -V chapterstyle=hikma-article \
106 -V pagestyle=ath \
107 -t html5 --toc \
108 --template=$(PREFIX)/templates/html5.template \
109 -o $@ $<
110 @echo "$(OK_COLOR)All done!$(NO_COLOR)"
112 %.docx: %.md
113 @echo "$(WARN_COLOR)Converting Markdown to .docx using standard template...$(NO_COLOR)"
114 $(PANDOC) -r $(FORMAT) -w docx -S \
115 --default-image-extension=png \
116 --template=$(PREFIX)/templates/odt.template \
117 -s --toc \
118 -o $@ $<;
119 @echo "$(OK_COLOR)All done!$(NO_COLOR)"
121 clean:
122 @echo "$(WARN_COLOR)Deleting all existing targets...$(NO_COLOR)"
123 rm -f $(addsuffix .html, $(BASE)) $(addsuffix .pdf, $(BASE)) \
124 $(addsuffix .docx, $(BASE))