Skip to content

Commit 8c45c6a

Browse files
option to adjust image root folder
1 parent e4dd886 commit 8c45c6a

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

Diff for: README.md

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ tubaina.sh folder/ -html -showNotes -native
1010
-showNotes exposes instructor comments notes (optional, default hide notes)
1111
-native runs outside Docker (optional, default runs inside Docker)
1212
-dockerImage repo/image (optional, default casadocodigo/gitbook)
13+
-imageRoot folder/ (optional)
14+
-help print usage
1315
1416
On your book source folder, add a book.properties with optional book configurations:
1517
TITLE="Your Title"

Diff for: tubaina2.sh

+17-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function show_help {
1111
echo " -showNotes exposes instructor comments notes (optional, default hide notes)"
1212
echo " -native runs outside Docker (optional, default runs inside Docker)"
1313
echo " -dockerImage repo/image (optional, default casadocodigo/gitbook)"
14+
echo " -imageRoot folder/ (optional)"
15+
echo " -help print usage"
1416
echo
1517
echo "On your book source folder, add a book.properties with optional book configurations:"
1618
echo ' TITLE="Your Title"'
@@ -34,7 +36,7 @@ if [ ! -d "$SRCDIR" ]; then
3436
exit 1
3537
fi
3638

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" "$@"`
3840
if [ $? != 0 ] ; then echo; show_help; exit 1 ; fi
3941
eval set -- "$OPTS"
4042

@@ -46,6 +48,7 @@ while true; do
4648
--showNotes) SHOW_NOTES=true; shift;;
4749
--native) NATIVE=true; shift;;
4850
--html|--epub|--mobi|--pdf|--ebooks) OUTPUT_FORMAT="$1"; shift;;
51+
--imageRoot) IMAGE_ROOT_FOLDER=$2; shift 2;;
4952
--help) show_help; exit 0;;
5053
--) shift; break;;
5154
* ) break ;;
@@ -263,6 +266,15 @@ function notes {
263266
fi
264267
}
265268

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|!\[\(.*\)\](\(.*\))|![\1]($IMAGE_ROOT_FOLDER/\2)|" $file
274+
done
275+
fi
276+
}
277+
266278
function html {
267279
echo "Generating html"
268280
copy
@@ -272,6 +284,7 @@ function html {
272284
generate_book_json html
273285
cover
274286
notes
287+
adjust_image_root_folder
275288

276289
CHAPTERS=()
277290
for file_path in "$BUILDDIR"/*.md; do
@@ -334,6 +347,7 @@ function epub {
334347
generate_book_json epub
335348
cover
336349
notes
350+
adjust_image_root_folder
337351
run gitbook epub -v
338352
echo "[tubaina] Generated epub: $BUILDDIR/book.epub"
339353
}
@@ -347,6 +361,7 @@ function mobi {
347361
generate_book_json mobi
348362
cover
349363
notes
364+
adjust_image_root_folder
350365
run gitbook mobi -v
351366
echo "[tubaina] Generated mobi: $BUILDDIR/book.mobi"
352367
}
@@ -363,6 +378,7 @@ function pdf {
363378
generate_book_json pdf
364379
cover
365380
notes
381+
adjust_image_root_folder
366382
run gitbook pdf -v
367383
echo "[tubaina] Generated PDF: $BUILDDIR/book.pdf"
368384
}

0 commit comments

Comments
 (0)