forked from mschroen/Science.md
-
Notifications
You must be signed in to change notification settings - Fork 7
/
make.bat
78 lines (63 loc) · 3.08 KB
/
make.bat
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
@echo off
REM science.md
REM A windows batch file which does exactly the same thing as `make all`.
REM Set NAME of the project, defaults to the parent folder name.
for %%a in (.) do set NAME=%%~nxa
@echo %NAME%
REM Merge Markdown
@echo "| cat content/*.md > release/%NAME%.md"
cd content && cat ^
title.md ^
abstract.md ^
introduction.md ^
methods.md ^
results.md ^
conclusion.md ^
appendix.md ^
acknowledgements.md ^
bib.md ^
> ../release/%NAME%.md
for %%I in (%NAME%.md) do @echo "> Bytes: %%~znI.md"
@echo.
REM make HTML
@echo "| pandoc release/%NAME%.md -o release/%NAME%.html"
cp ../release/%NAME%.md ../release/%NAME%.md.temp
sed -i -- 's/==TODO==/^<span class="todo"^>TODO^<\/span^>/g' ../release/%NAME%.md.temp
sed -i -- 's/==\([a-zA-Z]\+\) \([^^=]\+\)==/^<span class="comment \1"^>^<b^>\1^<\/b^> \2^<\/span^>/g' ../release/%NAME%.md.temp
cd ../release && pandoc --wrap=preserve -s -smart --filter pandoc-crossref --filter pandoc-citeproc -f markdown ^
--template templates/pandoc.html -t html5 --mathjax --number-sections -M secPrefix=section -M tblPrefix=Table ^
%NAME%.md.temp -o %NAME%.html
for %%I in (%NAME%.html) do @echo "> Bytes: %%~znI.html"
@echo.
REM make Word
@echo "| pandoc -o release/%NAME%.docx release/%NAME%.md"
cp ../release/%NAME%.md ../release/%NAME%.md.temp
sed -i -- 's/==TODO==/^<span custom-style="TODO"^> TODO ^<\/span^>/g' ../release/%NAME%.md.temp
sed -i -- 's/==\([a-zA-Z]\+\) \([^^=]\+\)==/^<span custom-style="comment-name"^> \1 ^<\/span^>^<span custom-style="comment"^> \2^<\/span^>/g' ../release/%NAME%.md.temp
cd ../release && pandoc --wrap=preserve -s -smart --filter pandoc-crossref --filter=pandoc-citeproc -f markdown ^
--number-sections -M numberSections=true -M secPrefix=section -M tblPrefix=Table ^
--reference-doc=templates/reference.docx ^
%NAME%.md.temp -o %NAME%.docx
for %%I in (%NAME%.docx) do @echo "> Bytes: %%~znI.docx"
@echo.
REM make LaTeX
@echo "| pandoc -o release/%NAME%.tex release/%NAME%.md "
cp ../release/%NAME%.md ../release/%NAME%.md.temp
sed -i -- 's/==TODO==/\\\\TODO/g' ../release/%NAME%.md.temp
sed -i -- 's/==\([a-zA-Z][^^=]\+\)==/\*\\\\\1\*/g' ../release/%NAME%.md.temp
sed -i -- 's/\.png/\.pdf/g' ../release/%NAME%.md.temp
cd ../release && pandoc --wrap=preserve -s -smart --filter pandoc-crossref --filter=pandoc-citeproc -f markdown ^
-V colorlinks -V papersize=a4 -V geometry=margin=1in --number-sections -M secPrefix=section -M tblPrefix=Table ^
--template templates/pandoc.tex %NAME%.md.temp -o %NAME%.tex
for %%I in (%NAME%.tex) do @echo "> Bytes: %%~znI.tex"
@echo.
REM make PDF
@echo "| pandoc -o release/%NAME%.pdf release/%NAME%.md "
cd ../release && pandoc --wrap=preserve -s -smart --filter pandoc-crossref --filter=pandoc-citeproc -f markdown ^
-V colorlinks -V papersize=a4 -V geometry=margin=1in --number-sections -M secPrefix=section -M tblPrefix=Table ^
--template templates/pandoc.tex %NAME%.md.temp -o %NAME%.pdf
for %%I in (%NAME%.pdf) do @echo "> Bytes: %%~znI.pdf"
@echo.
rm ../release/%NAME%.md.temp
REM require any key before close.
pause