blob: c2345a4daefdb16077f3879f6469513bd8d4ff72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/usr/bin/sh
unset LOCAL_CSS_PATH
unset WEB_CSS_PATH
CSS="$1"
shift
get_css_path() {
# Used to set WEB_CSS_PATH
pup "link[rel=stylesheet] attr{href}" -f "$1"
}
stylesheet_replace() {
# Replace each stylesheet href value with LOCAL_CSS_PATH
while [ -n "$1" ]; do
sed -i 's|'"$(pup link[rel=stylesheet] -f "$1")"'|<link rel="stylesheet" type="text/css" href="manual.css">|g' "$1"
shift
done
}
stylesheet_remove() {
# Remove the stylesheet link
while [ -n "$1" ]; do
sed -i 's|'"$(pup link[rel=stylesheet] -f "$1")"'||g' "$1"
shift
done
}
if [ "$CSS" = "yes" ]; then
WEB_CSS_PATH="$(get_css_path "$1")"
if [ -n "$WEB_CSS_PATH" ]; then
LOCAL_CSS_PATH="$(dirname "$1")"/manual.css
curl -o "$LOCAL_CSS_PATH" "$WEB_CSS_PATH"
fi
if [ -r "$LOCAL_CSS_PATH" ]; then
stylesheet_replace "$@"
else
CSS="no"
fi
fi
if [ "$CSS" = "no" ]; then
stylesheet_remove "$@"
fi
|