-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
21 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
toc.html: template.html toc.awk | ||
./toc2.awk $< > $@ | ||
./toc.awk $< > $@ | ||
|
||
index.html: template.html toc.html | ||
m4 $< > $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,30 @@ | ||
#!/usr/bin/awk -f | ||
|
||
BEGIN { print "<ul>" } | ||
END { print "</ul>" } | ||
|
||
/head[2345]\(/ { | ||
printf "\t" | ||
function make_id(s, ret) { | ||
ret = tolower(s) | ||
gsub(/ +/, "-", ret) | ||
return ret | ||
} | ||
|
||
/head2\(/ { | ||
last_level = 2 | ||
if (sublist) { | ||
print "</ul>" # close previous sublist | ||
sublist = 0 | ||
} | ||
match($0, /head2\(([^)]+)\)/, arr) | ||
printf "<li><a href=\"#%s\">%s</a></li>\n", make_id(arr[1]), arr[1] | ||
BEGIN { | ||
HEAD = "head([2345])\\(([^)]+)\\)" | ||
} | ||
END { print "</ul>" } | ||
|
||
/head3\(/ { | ||
last_level = 3 | ||
if (!sublist) { | ||
print "<ul>" | ||
$0 ~ HEAD { | ||
match($0, HEAD, arr) | ||
cur = arr[1] # current heading level | ||
while (p > 0 && cur < buf[p-1]) { | ||
#printf("closing list with cur = %d, last = %d\n", cur, buf[p-1]) | ||
print "</ul>" | ||
p-- | ||
} | ||
sublist = 1 | ||
printf "\t" | ||
match($0, /head3\(([^)]+)\)/, arr) | ||
printf "<li><a href=\"#%s\">%s</a></li>\n", make_id(arr[1]), arr[1] | ||
} | ||
|
||
/head4\(/ { | ||
last_level = 4 | ||
print "<ul>" # always add a list level for this, assume it's alone | ||
printf "\t\t" | ||
match($0, /head4\(([^)]+)\)/, arr) | ||
printf "<li><a href=\"#%s\">%s</a></li>\n", make_id(arr[1]), arr[1] | ||
print "</ul>" | ||
} | ||
|
||
/head5\(/ { | ||
last_level = 5 | ||
if (last_level != 4) { | ||
print "<ul>" # always add a list level for this, assume it's alone | ||
if (buf[p-1] < cur) { | ||
#printf "opening new list with cur = %d, last = %d\n", cur, buf[p-1] | ||
print "<ul>" | ||
} | ||
printf "\t\t" | ||
match($0, /head5\(([^)]+)\)/, arr) | ||
printf "<li><a href=\"#%s\">%s</a></li>\n", make_id(arr[1]), arr[1] | ||
print "</ul>" | ||
} | ||
if (buf[p-1] != arr[1]) | ||
buf[p++] = arr[1] # heading level stack | ||
|
||
function make_id(s, ret) { | ||
ret = tolower(s) | ||
gsub(/ +/, "-", ret) | ||
return ret | ||
printf "<li><a href=\"#%s\">%s</a></li>\n", make_id(arr[2]), arr[2] | ||
} |
This file was deleted.
Oops, something went wrong.