File: toc1.sh

package info (click to toggle)
html-xml-utils 7.7-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,488 kB
  • sloc: ansic: 11,213; sh: 7,996; lex: 243; makefile: 193; yacc: 125
file content (37 lines) | stat: -rwxr-xr-x 966 bytes parent folder | download | duplicates (4)
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
:
trap 'rm $TMP1 $TMP2' 0
TMP1=`mktemp /tmp/tmp.XXXXXXXXXX` || exit 1
TMP2=`mktemp /tmp/tmp.XXXXXXXXXX` || exit 1

./hxtoc -d -t >$TMP1 <<-EOF
	<title>Test</title>
	<h1>Document heading</h1>
	<!--toc-->
	<section>
	<h1>Second-level heading</h1>
	<section>
	<h6>Third-level heading</h6>
	</section>
	</section>
EOF
echo >>$TMP1			# Add newline

cat >$TMP2 <<-EOF
<html><head><title>Test</title></head><body><h1 id="document-heading">Document heading</h1><!--begin-toc-->
<ul class="toc">
<li><a href="#document-heading">Document heading</a>
 <ul class="toc">
 <li><a href="#second-level-heading-third-level-heading">Second-level heading</a>
  <ul class="toc">
  <li><a href="#third-level-heading-">Third-level heading</a>
  </ul>
 </ul></ul>
<!--end-toc--><section id="second-level-heading-third-level-heading">
<h1>Second-level heading</h1>
<section id="third-level-heading-">
<h6>Third-level heading</h6>
</section>
</section></body></html>
EOF

cmp -s $TMP1 $TMP2