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
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).
32 # Optional folder for manuscript
35 # Location of Pandoc support files.
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
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 # --------------------
66 # --------------------
67 # All markdown files in the working directory
68 SRC
= $(wildcard $(MS_DIR
)/*.
$(MEXT
))
69 BASE
= $(basename $(SRC
))
74 MS_DIR_FOR_TEX
= "$(MS_DIR)/"
82 all: clean $(HTML
) $(DOCX
) $(PDF
)
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
)
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 \
99 @echo
"$(OK_COLOR)All done!$(NO_COLOR)"
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 \
108 --template
=$(PREFIX
)/templates
/html5.template \
110 @echo
"$(OK_COLOR)All done!$(NO_COLOR)"
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 \
119 @echo
"$(OK_COLOR)All done!$(NO_COLOR)"
122 @echo
"$(WARN_COLOR)Deleting all existing targets...$(NO_COLOR)"
123 rm -f
$(addsuffix .html
, $(BASE
)) $(addsuffix .pdf
, $(BASE
)) \
124 $(addsuffix .docx
, $(BASE
))