-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmmf
76 lines (62 loc) · 1.95 KB
/
mmf
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
@echo off
:: Path to script repository
SET scriptPath=%~dp0
:: Path to assets for mmf repository
SET mmfPath=%scriptPath:~0,-1%\mmf
:: Help
if [%1]==[--help] (
echo.
echo **********************************************************
echo.
echo mmf : Make Magic Files
echo.
echo generates files from markdown
echo.
echo *_prez.txt files get transformed to impressjs presentations
echo.
echo mmf is enough. Use -s to generate get started files
echo.
goto :eof
)
:: Load get started document
if [%1]==[-s] (
xcopy %mmfPath%\start /D /E /C /R /I /K /Y
) else (
:: Move prez files to avoid useless convertions
mkdir mmfTmp
move *_prez.txt mmfTmp
:: For each .txt file in repository
for %%f in (*.txt) do (
:: Create a word document thanks to a template
pandoc -s -S --reference-docx %mmfPath%\template.docx %%~nf.txt -o %%~nf.docx
:: Create an ebook using epub format
pandoc -s -S --epub-stylesheet %mmfPath%\ebook.css %%~nf.txt -o %%~nf.epub
:: Create a html file using material design css
pandoc -s -S --toc -H %mmfPath%\pandoc.css %%~nf.txt -o %%~nf.html
:: Create a pdf using LaTeX
pandoc -N --template=%mmfPath%\template.tex %%~nf.txt --latex-engine=xelatex -o %%~nf.pdf
:: Create an ebook using Kindle format
:: kindlegen %%~nf.epub
)
:: Move new documents except .html for link reason
if exist *.epub mkdir doc\epub
move *.epub doc\epub
if exist *.mobi mkdir doc\mobi
move *.mobi doc\mobi
if exist *.pdf mkdir doc\pdf
move *.pdf doc\pdf
if exist *.docx mkdir doc\docx
move *.docx doc\docx
:: prez are now safe. Bring them back
move mmfTmp\*.txt
rd mmfTmp
:: prez creation
if exist *_prez.txt mkdir impressjs
:: copy assets needed by impressjs
if exist *_prez.txt xcopy %mmfPath%\impressjs impressjs\ /D /E /C /R /I /K /Y
:: Convert txt file to impressjs presentation
for %%f in (*_prez.txt) do (
pandoc --template impressjs\template\impress_template.html -V impress-url=impressjs\js\impress.js -s -t html5 --section-divs -o %%~nf.html %%~nf.txt
)
)
:: End