blob: 97fa4459f1f0941a80da9c4b33832b84e6ff6cda (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/bin/rc -e
rfork E
# htwrap -- create standalone HTML document
flagfmt='t, c charset, d dir, l lang, v doctype'
args='[file ...]'
if(! ifs=() eval `{aux/getflags $*}){
aux/usage
exit usage
}
switch($flagv){
case 5
echo '<!DOCTYPE html>'
case 4
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">'
case 4s
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">'
case x xhtml
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
case xs xhtmls
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
case ''
echo '<!DOCTYPE html>'
case *
echo error: unknown doctype $flagv >[1=2]
aux/usage
exit usage
}
echo -n '<html'
if(! ~ $#flagl 0) echo -n ' lang="'^$flagl^'"'
if(! ~ $#flagd 0) echo -n ' dir="'^$flagd^'"'
echo '>'
if(! ~ $#flagc 0)
echo '<meta http-equiv="Content-Type" content="text/html; charset='^$flagc^'">'
fn source{
if(! ~ $#* 0)
cat $*
if not
cat
}
if(! ~ $#flagt 0) # try to retrieve title from <h1> on first line
source $* | sed '1s/^<h1>(.*)<\/h1>/<title>\1<\/title>\n&/'
if not
source $*
echo '</html>'
|