Skip to content

Commit 0352221

Browse files
committed
support html output
1 parent 6aa919e commit 0352221

File tree

1 file changed

+54
-8
lines changed

1 file changed

+54
-8
lines changed

build.sh

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ do_gitversion="no"
66
do_gitstatus="no"
77
pdf_output=""
88
docx_output=""
9+
html_output=""
910
latex_output=""
1011
table_rules="no"
1112

@@ -31,6 +32,7 @@ print_usage() {
3132
echo " --docx=output: enable outputing of docx and specify the output file name."
3233
echo " --pdf=output: enable outputing of pdf and specify the output file name."
3334
echo " --latex=output: enable outputing of latex and specify the output file name."
35+
echo " --html=output: enable outputing of html and specify the output file name."
3436
echo
3537
echo "Miscellaneous"
3638
echo " --resourcedir=dir: Set the resource directory, defaults to root for pandoc containers"
@@ -41,7 +43,7 @@ print_usage() {
4143
}
4244

4345

44-
if ! options=$(getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,table_rules,pdf:,latex:,docx:,resourcedir: --options="" -- "$@"); then
46+
if ! options=$(getopt --longoptions=help,puppeteer,notmp,gitversion,gitstatus,table_rules,pdf:,latex:,docx:,html:,resourcedir: --options="" -- "$@"); then
4547
echo "Incorrect options provided"
4648
print_usage
4749
exit 1
@@ -79,6 +81,10 @@ while true; do
7981
pdf_output="${2}"
8082
shift 2
8183
;;
84+
--html)
85+
html_output="${2}"
86+
shift 2
87+
;;
8288
--resourcedir)
8389
resource_dir="${2}"
8490
shift 2
@@ -115,8 +121,8 @@ if [ ! -e "${input_file}" ]; then
115121
exit 1
116122
fi
117123

118-
if [ -z "${pdf_output}${latex_output}${docx_output}" ]; then
119-
>&2 echo "Expected --pdf, --docx or --latex option"
124+
if [ -z "${pdf_output}${latex_output}${docx_output}${html_output}" ]; then
125+
>&2 echo "Expected --pdf, --docx, --html, or --latex option"
120126
print_usage
121127
exit 1
122128
fi
@@ -198,6 +204,7 @@ echo "file: ${input_file}"
198204
echo "docx: ${docx_output:-none}"
199205
echo "pdf: ${pdf_output:-none}"
200206
echo "latex: ${latex_ouput:-none}"
207+
echo "html: ${html_ouput:-none}"
201208
echo "use tmp: ${is_tmp}"
202209
echo "resource dir: ${resource_dir}"
203210
echo "build dir: ${build_dir}"
@@ -291,8 +298,6 @@ if [ -n "${pdf_output}" ]; then
291298
--metadata=crossrefYaml:/resources/filters/pandoc-crossref.yaml \
292299
--metadata=logo:/resources/img/tcg.png \
293300
--metadata=titlepage-rule-height:0 \
294-
--metadata=tables-vrules:true \
295-
--metadata=tables-hrules:true \
296301
--metadata=colorlinks:true \
297302
--metadata=contact:[email protected] \
298303
--from=markdown+implicit_figures+grid_tables+table_captions-markdown_in_html_blocks \
@@ -315,7 +320,7 @@ if [ -n "${latex_output}" ]; then
315320
--standalone \
316321
--template=eisvogel.latex \
317322
--filter=mermaid-filter \
318-
--lua-filter=center-images \
323+
--lua-filter=center-images.lua \
319324
--lua-filter=parse-html.lua \
320325
--filter=pandoc-crossref \
321326
--lua-filter=divide-code-blocks.lua \
@@ -331,8 +336,6 @@ if [ -n "${latex_output}" ]; then
331336
--metadata=crossrefYaml:/resources/filters/pandoc-crossref.yaml \
332337
--metadata=logo:/resources/img/tcg.png \
333338
--metadata=titlepage-rule-height:0 \
334-
--metadata=tables-vrules:true \
335-
--metadata=tables-hrules:true \
336339
--metadata=colorlinks:true \
337340
--metadata=contact:[email protected] \
338341
--from=markdown+implicit_figures+grid_tables+table_captions-markdown_in_html_blocks \
@@ -372,6 +375,49 @@ if [ -n "${docx_output}" ]; then
372375
fi
373376
fi
374377

378+
export MERMAID_FILTER_FORMAT="svg"
379+
380+
# Generate the html output
381+
if [ -n "${html_output}" ]; then
382+
echo "Generating html Output"
383+
pandoc \
384+
--toc \
385+
-V colorlinks=true \
386+
-V linkcolor=blue \
387+
-V urlcolor=blue \
388+
-V toccolor=blue \
389+
--embed-resources \
390+
--standalone \
391+
--filter=mermaid-filter \
392+
--lua-filter=center-images.lua \
393+
--lua-filter=parse-html.lua \
394+
--filter=pandoc-crossref \
395+
--lua-filter=divide-code-blocks.lua \
396+
--resource-path=.:/resources \
397+
--data-dir=/resources \
398+
--top-level-division=section \
399+
--variable=block-headings \
400+
--variable=numbersections \
401+
--metadata=date-english:"${DATE_ENGLISH}" \
402+
--metadata=year:"${YEAR}" \
403+
--metadata=titlepage:true \
404+
--metadata=titlepage-background:/resources/img/cover.png \
405+
--metadata=crossrefYaml:/resources/filters/pandoc-crossref.yaml \
406+
--metadata=logo:/resources/img/tcg.png \
407+
--metadata=titlepage-rule-height:0 \
408+
--metadata=colorlinks:true \
409+
--metadata=contact:[email protected] \
410+
--from=markdown+implicit_figures+grid_tables+table_captions-markdown_in_html_blocks \
411+
${extra_pandoc_options} \
412+
--to=html \
413+
"${build_dir}/${input_file}.3" \
414+
--output="${html_output}"
415+
echo "HTML Output Generated to file: ${html_output}"
416+
if [ $? -ne 0 ]; then
417+
RESULT=$?
418+
fi
419+
fi
420+
375421
if [ ${RESULT} -ne 0 ]; then
376422
exit 1
377423
fi

0 commit comments

Comments
 (0)