Skip to content

Commit 65841c2

Browse files
committed
preprocess: package after wget and process
1 parent 720db33 commit 65841c2

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

make_chm.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ PHP="${PHP:-$(which php)}"
3232
ICONV="${ICONV:-$(which iconv)}"
3333
HHC="${HHC:-$(which hhc)}"
3434
_7Z="${_7Z:-$(which 7z)}"
35-
VERSION="${VERSION:-$(date +%Y%m)}"
35+
VERSION="${VERSION:-$(date +%Y%m%d)}"
3636
CPUS="$(cat /proc/cpuinfo | grep -c '^processor')"
3737

3838
# 在执行下一步之前,移动reference或output目录下文件到当前目录

preprocess-zh.sh

100644100755
Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
#!/bin/bash
2+
for i in "$@"
3+
do
4+
case $i in
5+
_7Z=*)
6+
_7Z="${i#*=}"
7+
shift # past argument=value
8+
;;
9+
VERSION=*)
10+
VERSION="${i#*=}"
11+
shift # past argument=value
12+
;;
13+
*)
14+
# unknown option
15+
;;
16+
esac
17+
done
218

319
set -e
420
git clone https://github.com/PeterFeicht/cppreference-doc.git --depth=1
@@ -25,8 +41,14 @@ ext_path="$(find | grep -iP 'load\.php.*?modules=.*ext.*&only=styles.*?' | head
2541

2642
LIST="startup_scripts site_scripts site_modules skin_scripts ext"
2743
extra_fonts="DejaVuSans.ttf DejaVuSans-Bold.ttf DejaVuSansMono.ttf DejaVuSansMono-Bold.ttf"
44+
45+
_7Z="${_7Z:-$(which 7z)}"
46+
VERSION="${VERSION:-$(date +%Y%m%d)}"
2847
CPUS="$(cat /proc/cpuinfo | grep -c '^processor')"
2948

49+
# package un-processed files
50+
"${_7Z}" -mx9 -myx9 "cppreference-unprocessed-${VERSION}.7z" ./reference
51+
3052
# https://gist.github.com/cdown/1163649/8a35c36fdd24b373788a7057ed483a5bcd8cd43e
3153
url_encode() {
3254
local _length="${#1}"
@@ -90,6 +112,8 @@ done
90112
fi
91113
rm -rf font_temp
92114

115+
find ./ -iname '*.html' -type f | xargs -P "${CPUS}" sed -i "s/ - cppreference.com//g"
116+
93117
echo post-processing...
94118
for i in $LIST; do
95119
echo processing $i
@@ -103,5 +127,10 @@ find -iname "${skin_scripts_replace}" | xargs sed -i '1 i if(window.mw)'
103127
find -iname '*.css' | xargs sed -i -r 's/\.\.\/([^.]+?)\.ttf/\1.ttf/ig'
104128
echo Done.
105129

106-
mv reference/* ../
130+
# package processed files
131+
"${_7Z}" -mx9 -myx9 "html-book-${VERSION}.7z" ./reference
132+
133+
# move processed files to parent folder
134+
# for make_chm.sh
135+
mv -f reference/* ../
107136
cd ..

0 commit comments

Comments
 (0)