aboutsummaryrefslogtreecommitdiff
path: root/index
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-01-31 12:51:28 +0000
committerJohn Ankarström <john@ankarstrom.se>2021-01-31 12:51:28 +0000
commit07f59f5eb8c296b7306882185cbe932a2f286174 (patch)
treed82ea0d882cc07a399a3c0257e85b3f94f626a65 /index
parentdfb9b24814264abb429e4d289685654c469ff362 (diff)
downloadem-07f59f5eb8c296b7306882185cbe932a2f286174.tar.gz
Rename index to htindex (like htwrap)
Diffstat (limited to 'index')
-rwxr-xr-xindex74
1 files changed, 0 insertions, 74 deletions
diff --git a/index b/index
deleted file mode 100755
index accd0be..0000000
--- a/index
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/rc -e
-
-# index -- add ids to headings and print index to stderr
-
-flagfmt=s
-args='[file ...]'
-
-if(! ifs=() eval `{aux/getflags $*}){
- aux/usage
- exit usage
-}
-
-fn source{
- if(! ~ $#* 0)
- cat $*
- if not
- cat
-}
-
-source $* | awk '
- /<h[0-9]>.*<\/h[0-9]/ {
- heading($0)
- next
- }
- /<h[0-9]>/ {
- open = 1
- s = $0
- next
- }
- open && /<\/h[0-9]>/ {
- open = 0
- s = s "\n" $0
- heading(s)
- next
- }
- open { s = s " " $0; next }
- { print }
-
- function heading(s) {
- i = s
- sub("^.*<h[0-9]>", "", i)
- sub("</h[0-9]>.*$", "", i)
- i = toascii(i)
- sub("^<h[0-9]", "& id=\"" i "\"", s)
- print s
- if (!ENVIRON["flags"]) { # if not silent mode
- sub("^<h", "", s)
- sub(" id=\"", " ", s)
- sub("\">", " ", s)
- sub("<\/h[0-9]>$", "", s)
- print s > "/dev/stderr"
- }
- }
-
- function toascii(s) {
- s = tolower(s)
- gsub("[ÀÁÂÃÄÅàáâãäå]", "a", s)
- gsub("[Ææ]", "ae", s)
- gsub("[Çç]", "c", s)
- gsub("[Ðð]", "dh", s)
- gsub("[ÈÉÊËèéêë]", "e", s)
- gsub("[ÌÍÎÏìíîï]", "i", s)
- gsub("[Ññ]", "n", s)
- gsub("[ÒÓÔÕÖØòóôõöø]", "o", s)
- gsub("[ß]", "ss", s)
- gsub("[Þþ]", "th", s)
- gsub("[ÙÚÛÜùúûü]", "u", s)
- gsub("[×]", "x", s)
- gsub("[Ýýÿ]", "y", s)
- gsub("[^-a-z_ ]", "", s)
- gsub("[ ]+", "-", s)
- return s
- }
-'