@@ -52,6 +52,16 @@ function downloadLib() {
5252 fi
5353}
5454
55+ function downloadLibs() {
56+
57+ downloadLib https://github.com/hakimel/reveal.js/archive/3.6.0.zip \
58+ reveal.js-3.6.0 reveal.js
59+ downloadLib https://github.com/denehyg/reveal.js-menu/archive/1.2.0.zip \
60+ reveal.js-menu-1.2.0 reveal.js-menu
61+ downloadLib https://github.com/e-gor/Reveal.js-Title-Footer/archive/master.zip \
62+ Reveal.js-Title-Footer-master reveal.js-title-footer
63+ }
64+
5565function initLibFolder() {
5666
5767 LIB_FOLDER=" $1 /lib"
@@ -102,14 +112,22 @@ function initExportFolder() {
102112
103113function normalizeImages() {
104114
105- # close div after .png)
106- sed -i ' s/.png)$/.png){ width=80% text-align=center }\n/g' " ../export/$1 -to-$2 .md"
107-
108- # close div after .jpg)
109- sed -i ' s/.jpg)$/.jpg){ width=80% text-align=center }\n/g' " ../export/$1 -to-$2 .md"
115+ if [ " $2 " == " slides" ]; then
116+ # close div after .png)
117+ sed -i ' s/.png)$/.png){ width=80% class=center }\n/g' " ../export/$1 -to-$2 .md"
118+ # close div after .jpg)
119+ sed -i ' s/.jpg)$/.jpg){ width=80% class=center }\n/g' " ../export/$1 -to-$2 .md"
120+ # close div after .gif)
121+ sed -i ' s/.gif)$/.gif){ width=80% class=center }\n/g' " ../export/$1 -to-$2 .md"
122+ else
123+ # close div after .png)
124+ sed -i ' s/.png)$/.png){ width=50% class=center }\n/g' " ../export/$1 -to-$2 .md"
125+ # close div after .jpg)
126+ sed -i ' s/.jpg)$/.jpg){ width=50% class=center }\n/g' " ../export/$1 -to-$2 .md"
127+ # close div after .gif)
128+ sed -i ' s/.gif)$/.gif){ width=50% class=center }\n/g' " ../export/$1 -to-$2 .md"
129+ fi
110130
111- # close div after .gif)
112- sed -i ' s/.gif)$/.gif){ width=80% text-align=center }\n/g' " ../export/$1 -to-$2 .md"
113131}
114132
115133function convertMainListsIntoParagraphs() {
@@ -130,17 +148,17 @@ function convertMainListsIntoParagraphs() {
130148
131149function normalizeMd() {
132150
133- echo -e " Normalizing... ../export/$1 -to-$2 .md"
151+ # replace multiple empty lines with one empty line
152+ sed -i ' /^$/N;/^\n$/D' " ../export/$1 -to-$2 .md"
153+ }
134154
135- # remove blank lines
136- sed -i ' /^$/d' " ../export/$1 -to-$2 .md"
155+ function replaceNotes() {
137156
138- # add new line before #
139- sed -i ' :a;N;$!ba;s/\n#/\n\n#/g' " ../export/$1 -to-$2 .md"
140- sed -i ' :a;N;$!ba;s/\n #/\n\n #/g' " ../export/$1 -to-$2 .md"
157+ # replace @start-notes with <aside class="notes">
158+ sed -i ' s/^@start-notes/<aside class="notes">/g' " ../export/$1 -to-$2 .md"
141159
142- # replace multiple empty lines with one empty line
143- sed -i ' /^$/N;/^\n$/D ' " ../export/$1 -to-$2 .md"
160+ # replace @end-notes with </aside>
161+ sed -i ' s/^@end-notes/<\/aside>/g ' " ../export/$1 -to-$2 .md"
144162}
145163
146164function cleanMdToSlides() {
@@ -154,15 +172,11 @@ function cleanMdToSlides() {
154172 sed -i ' s/###*/##/g' " ../export/$1 -to-slides.md"
155173 sed -i ' s/##\\#/###/g' " ../export/$1 -to-slides.md"
156174
157- # normalizeMd $1 slides
158-
159175 normalizeImages " $1 " slides
160176
161- # replace @start-notes with <aside class="notes">
162- sed -i ' s/^@start-notes/<aside class="notes">/g' " ../export/$1 -to-slides.md"
177+ replaceNotes " $1 " slides
163178
164- # replace @end-notes with </aside>
165- sed -i ' s/^@end-notes/<\/aside>/g' " ../export/$1 -to-slides.md"
179+ normalizeMd " $1 " slides
166180}
167181
168182function cleanMdToBook() {
@@ -177,32 +191,40 @@ function cleanMdToBook() {
177191 # remove (I) from lines
178192 sed -i ' s/ (I)//g' " ../export/$1 -to-book.md"
179193
180- # remove all lines with (I ) (II )...
181- sed -i ' s/.*(I.*/ /g' " ../export/$1 -to-book.md"
182- sed -i ' s/.*(V.*/ /g' " ../export/$1 -to-book.md"
183- sed -i ' s/.*(X.*/ /g' " ../export/$1 -to-book.md"
194+ # remove all lines with (II ) (III )...
195+ sed -i ' s/^# .*(I.*$/@delete /g' " ../export/$1 -to-book.md"
196+ sed -i ' s/^# .*(V.*$/@delete /g' " ../export/$1 -to-book.md"
197+ sed -i ' s/^# .*(X.*$/@delete /g' " ../export/$1 -to-book.md"
184198
185- # normalizeMd $1 book
199+ sed -i ' :a;N;$!ba;s/\n@delete\n\n//g ' " ../export/ $1 -to- book.md "
186200
187- # convertMainListsIntoParagraphs $1 book
201+ # convertMainListsIntoParagraphs "$1" book
188202
189203 normalizeImages " $1 " book
190204
191- # remove @start-notes
192- sed -i ' s/^@start-notes//g' " ../export/$1 -to-book.md"
205+ replaceNotes " $1 " book
193206
194- # remove @end-notes
195- sed -i ' s/^@end-notes//g' " ../export/$1 -to-book.md"
207+ # remove '> ' at the beginning of the line
208+ sed -i ' s/^> //g' " ../export/$1 -to-book.md"
209+
210+ # remove '--' at the beginning of the line
211+ sed -i ' s/^-*$//g' " ../export/$1 -to-book.md"
212+
213+ normalizeMd " $1 " book
196214}
197215
198216function buildRevealSlides() {
199217
200- downloadLib https://github.com/hakimel/reveal.js/archive/3.6.0.zip \
201- reveal.js-3.6.0 reveal.js
202- downloadLib https://github.com/denehyg/reveal.js-menu/archive/1.2.0.zip \
203- reveal.js-menu-1.2.0 reveal.js-menu
204- downloadLib https://github.com/e-gor/Reveal.js-Title-Footer/archive/master.zip \
205- Reveal.js-Title-Footer-master reveal.js-title-footer
218+ if [ " $REVEAL_JS_ONLINE " == " yes" ]; then
219+ REVEAL_JS_URL=$REVEAL_JS_URL_ONLINE
220+ REVEAL_JS_MENU_URL=$REVEAL_JS_MENU_URL_ONLINE
221+ REVEAL_JS_TITLE_FOOTER_URL=$REVEAL_JS_TITLE_FOOTER_URL_ONLINE
222+ else
223+ downloadLibs
224+ REVEAL_JS_URL=$REVEAL_JS_URL_OFFLINE
225+ REVEAL_JS_MENU_URL=$REVEAL_JS_MENU_URL_OFFLINE
226+ REVEAL_JS_TITLE_FOOTER_URL=$REVEAL_JS_TITLE_FOOTER_URL_OFFLINE
227+ fi
206228
207229 echo -e " Exporting... ../export/$1 -reveal-slides$2 .html"
208230
0 commit comments