1414 HHC=" ${i#* =} "
1515 shift # past argument=value
1616 ;;
17+ _7Z=* )
18+ _7Z=" ${i#* =} "
19+ shift # past argument=value
20+ ;;
21+ VERSION=* )
22+ VERSION=" ${i#* =} "
23+ shift # past argument=value
24+ ;;
1725 * )
1826 # unknown option
1927 ;;
2331PHP=" ${PHP:- $(which php)} "
2432ICONV=" ${ICONV:- $(which iconv)} "
2533HHC=" ${HHC:- $(which hhc)} "
34+ _7Z=" ${_7Z:- $(which 7z)} "
35+ VERSION=" ${VERSION:- $(date +% Y% m)} "
2636CPUS=" $( cat /proc/cpuinfo | grep -c ' ^processor' ) "
2737
2838# 在执行下一步之前,移动reference或output目录下文件到当前目录
@@ -47,4 +57,25 @@ mv "${i}" "chm_temp/${i}"
4757done
4858rm -rf chm_temp
4959
50- " ${HHC} " cppreference.hhp
60+ sed " s/cppreference\.chm/cppreference-zh-${VERSION} \.chm/" cppreference.hhp > " cppreference-zh-${VERSION} .hhp"
61+
62+ # Compile and package UTF-8 version
63+ " ${HHC} " " cppreference-zh-${VERSION} .hhp"
64+ " ${_7Z} " a -mx9 " cppreference-zh-${VERSION} -chm-project.7z" " cppreference-zh-${VERSION} .hhp" cppreference.{hhc,hhk} hh{a.dll,c.exe} chmhelp/*
65+
66+ # Convert HTML to GBK
67+ mv chmhelp chmhelp1
68+ mkdir -p chmhelp
69+ cd chmhelp1
70+
71+ find -iname ' *.html' | xargs -P " ${CPUS} " sed -i ' s/<meta http-equiv="Content-Type" content="text\/html; charset=utf-8" \/>/<meta http-equiv="Content-Type" content="text\/html; charset=gbk" \/>/'
72+ ls | grep .html | xargs -P " ${CPUS} " -I {} sh -c " ${ICONV} -c -f UTF-8 -t GBK '{}' > '../chmhelp/{}'"
73+ cp -n ./* ../chmhelp/
74+ cd ..
75+ rm -rf chmhelp1
76+
77+ sed " s/cppreference\.chm/cppreference-zh-${VERSION} -gbk\.chm/" cppreference.hhp > " cppreference-zh-${VERSION} -gbk.hhp"
78+
79+ # Compile and package GBK version
80+ " ${HHC} " " cppreference-zh-${VERSION} -gbk.hhp"
81+ " ${_7Z} " a -mx9 " cppreference-zh-${VERSION} -chm-project-gbk.7z" " cppreference-zh-${VERSION} -gbk.hhp" cppreference.{hhc,hhk} hh{a.dll,c.exe} chmhelp/*
0 commit comments