@@ -11,6 +11,8 @@ function show_help {
11
11
echo " -showNotes exposes instructor comments notes (optional, default hide notes)"
12
12
echo " -native runs outside Docker (optional, default runs inside Docker)"
13
13
echo " -dockerImage repo/image (optional, default casadocodigo/gitbook)"
14
+ echo " -imageRoot folder/ (optional)"
15
+ echo " -help print usage"
14
16
echo
15
17
echo " On your book source folder, add a book.properties with optional book configurations:"
16
18
echo ' TITLE="Your Title"'
@@ -34,7 +36,7 @@ if [ ! -d "$SRCDIR" ]; then
34
36
exit 1
35
37
fi
36
38
37
- OPTS=` getopt -a -l dockerImage: -l showNotes -l native -l html -l epub -l mobi -l pdf -l ebooks -l help -n ' tubaina2' -- " $0 " " $@ " `
39
+ OPTS=` getopt -a -l dockerImage: -l showNotes -l native -l html -l epub -l mobi -l pdf -l ebooks -l imageRoot: -l help -n ' tubaina2' -- " $0 " " $@ " `
38
40
if [ $? != 0 ] ; then echo ; show_help; exit 1 ; fi
39
41
eval set -- " $OPTS "
40
42
@@ -46,6 +48,7 @@ while true; do
46
48
--showNotes) SHOW_NOTES=true; shift ;;
47
49
--native) NATIVE=true; shift ;;
48
50
--html|--epub|--mobi|--pdf|--ebooks) OUTPUT_FORMAT=" $1 " ; shift ;;
51
+ --imageRoot) IMAGE_ROOT_FOLDER=$2 ; shift 2;;
49
52
--help) show_help; exit 0;;
50
53
--) shift ; break ;;
51
54
* ) break ;;
@@ -263,6 +266,15 @@ function notes {
263
266
fi
264
267
}
265
268
269
+ function adjust_image_root_folder {
270
+ if [[ $IMAGE_ROOT_FOLDER ]]; then
271
+ for file in " $BUILDDIR " /* .md; do
272
+ echo " [tubaina] Adjusting image root folder for $file "
273
+ sed -i -e " s|!\[\(.*\)\](\(.*\))||" $file
274
+ done
275
+ fi
276
+ }
277
+
266
278
function html {
267
279
echo " Generating html"
268
280
copy
@@ -272,6 +284,7 @@ function html {
272
284
generate_book_json html
273
285
cover
274
286
notes
287
+ adjust_image_root_folder
275
288
276
289
CHAPTERS=()
277
290
for file_path in " $BUILDDIR " /* .md; do
@@ -334,6 +347,7 @@ function epub {
334
347
generate_book_json epub
335
348
cover
336
349
notes
350
+ adjust_image_root_folder
337
351
run gitbook epub -v
338
352
echo " [tubaina] Generated epub: $BUILDDIR /book.epub"
339
353
}
@@ -347,6 +361,7 @@ function mobi {
347
361
generate_book_json mobi
348
362
cover
349
363
notes
364
+ adjust_image_root_folder
350
365
run gitbook mobi -v
351
366
echo " [tubaina] Generated mobi: $BUILDDIR /book.mobi"
352
367
}
@@ -363,6 +378,7 @@ function pdf {
363
378
generate_book_json pdf
364
379
cover
365
380
notes
381
+ adjust_image_root_folder
366
382
run gitbook pdf -v
367
383
echo " [tubaina] Generated PDF: $BUILDDIR /book.pdf"
368
384
}
0 commit comments