Changeset View
Changeset View
Standalone View
Standalone View
documentation/tools/asciidoctor.sh
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | build_pdf() { | ||||
local doc_type="$1" | local doc_type="$1" | ||||
local doc_lang="$2" | local doc_lang="$2" | ||||
local doc_name="$3" | local doc_name="$3" | ||||
local cur_dir_source="content/$doc_lang/$doc_type/$doc_name/" | local cur_dir_source="content/$doc_lang/$doc_type/$doc_name/" | ||||
local cur_dir_output="public/$doc_lang/$doc_type/$doc_name/" | local cur_dir_output="public/$doc_lang/$doc_type/$doc_name/" | ||||
local theme_font="" | |||||
if [ ! -d "$cur_dir_output" ]; then | if [ ! -d "$cur_dir_output" ]; then | ||||
mkdir -p "$cur_dir_output" | mkdir -p "$cur_dir_output" | ||||
fi | fi | ||||
if [ "$doc_type" = "books" ]; then | if [ "$doc_type" = "books" ]; then | ||||
local asciidoctor_type="book" | local asciidoctor_type="book" | ||||
if [ -f "${cur_dir_source}book.adoc" ]; then | if [ -f "${cur_dir_source}book.adoc" ]; then | ||||
local asciidoctor_file_name="book.adoc" | local asciidoctor_file_name="book.adoc" | ||||
else | else | ||||
local asciidoctor_file_name="_index.adoc" | local asciidoctor_file_name="_index.adoc" | ||||
fi | fi | ||||
fi | fi | ||||
if [ "$doc_type" = "articles" ]; then | if [ "$doc_type" = "articles" ]; then | ||||
local asciidoctor_type="article" | local asciidoctor_type="article" | ||||
local asciidoctor_file_name="_index.adoc" | local asciidoctor_file_name="_index.adoc" | ||||
fi | fi | ||||
# Check non default fonts | |||||
case "$doc_lang" in | |||||
zh-cn) | |||||
if [ ! -f "$LOCALBASE/share/docproj-fonts-cjk/NotoSansSC-Medium.otf" ]; then | |||||
echo " font not found, skipping pdf build" | |||||
return | |||||
fi | |||||
theme_font="-a scripts=cjk -a pdf-theme=./shared/zh-cn/zh-cn-theme.yml -a pdf-fontsdir=$LOCALBASE/share/docproj-fonts-cjk" | |||||
;; | |||||
zh-tw) | |||||
if [ ! -f "$LOCALBASE/share/docproj-fonts-cjk/NotoSansTC-Medium.otf" ]; then | |||||
echo " font not found, skipping pdf build" | |||||
return | |||||
fi | |||||
theme_font="-a pdf-theme=./shared/zh-tw/zh-tw-theme.yml -a pdf-fontsdir=$LOCALBASE/share/docproj-fonts-cjk/" | |||||
;; | |||||
*) | |||||
theme_font="-a pdf-theme=default-with-fallback-font" | |||||
;; | |||||
esac | |||||
$ASCIIDOCTORPDF_CMD \ | $ASCIIDOCTORPDF_CMD \ | ||||
-r ./shared/lib/man-macro.rb \ | -r ./shared/lib/man-macro.rb \ | ||||
-r ./shared/lib/git-macro.rb \ | -r ./shared/lib/git-macro.rb \ | ||||
-r ./shared/lib/packages-macro.rb \ | -r ./shared/lib/packages-macro.rb \ | ||||
-r ./shared/lib/inter-document-references-macro.rb \ | -r ./shared/lib/inter-document-references-macro.rb \ | ||||
-r ./shared/lib/sectnumoffset-treeprocessor.rb \ | -r ./shared/lib/sectnumoffset-treeprocessor.rb \ | ||||
-r ./shared/lib/cross-document-references-macro.rb \ | -r ./shared/lib/cross-document-references-macro.rb \ | ||||
--doctype="$asciidoctor_type" \ | --doctype="$asciidoctor_type" \ | ||||
-a skip-front-matter \ | -a skip-front-matter \ | ||||
-a lang="$doc_lang" \ | -a lang="$doc_lang" \ | ||||
-a isonline=1 \ | -a isonline=1 \ | ||||
-a env-beastie=1 \ | -a env-beastie=1 \ | ||||
-a pdf-theme=default-with-fallback-font \ | ${theme_font} \ | ||||
-o "${cur_dir_output}${doc_name}_${doc_lang}.pdf" \ | -o "${cur_dir_output}${doc_name}_${doc_lang}.pdf" \ | ||||
"${cur_dir_source}${asciidoctor_file_name}" | "${cur_dir_source}${asciidoctor_file_name}" | ||||
} | } | ||||
build_epub() { | build_epub() { | ||||
if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then | if [ "$1" = "" ] || [ "$2" = "" ] || [ "$3" = "" ]; then | ||||
exit 1 | exit 1 | ||||
▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines |