Skip to content

Commit 720db33

Browse files
committed
make_chm: add gbk making and packing script
remove the standalone make_gbk.sh
1 parent 5c444c6 commit 720db33

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

make_chm.sh

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ do
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
;;
@@ -23,6 +31,8 @@ done
2331
PHP="${PHP:-$(which php)}"
2432
ICONV="${ICONV:-$(which iconv)}"
2533
HHC="${HHC:-$(which hhc)}"
34+
_7Z="${_7Z:-$(which 7z)}"
35+
VERSION="${VERSION:-$(date +%Y%m)}"
2636
CPUS="$(cat /proc/cpuinfo | grep -c '^processor')"
2737

2838
# 在执行下一步之前,移动reference或output目录下文件到当前目录
@@ -47,4 +57,25 @@ mv "${i}" "chm_temp/${i}"
4757
done
4858
rm -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/*

make_gbk.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)