FIX: pipadoc index generation, replace non alnum chars with '__'
authorChristian Thaeter <ct@pipapo.org>
Mon, 16 Aug 2010 12:21:04 +0000 (14:21 +0200)
committerChristian Thaeter <ct@pipapo.org>
Mon, 16 Aug 2010 12:21:04 +0000 (14:21 +0200)
doc/asciidoc.pawk

index 130fba8..fe072c9 100644 (file)
@@ -13,7 +13,11 @@ match($0, com "([[:alpha:]][[:alnum:]_]*)(([.]([^[:space:]]*)))?", p) {
 match($0, com"(.*) PARA (.*); *(.*); *(.*)", p) {
     if(p[3])
     {
-        if (p[4]) append("index", tolower(p[3]), "xref:"p[3]"["p[2]"]:: "p[4])
+        if (p[4])
+        {
+            gsub(/[^[:alnum:]_]+/, "__", p[3])
+            append("index", tolower(p[3]), "xref:"p[3]"["p[2]"]:: "p[4])
+        }
         append(p[1],"","[["p[3]"]]")
     }
     append(p[1],"","."p[2])
@@ -59,6 +63,7 @@ match($0, com"(.*) HEAD([^ ]+) (.*); *(.*); *(.*)", p) {
     {
         if (p[4])
         {
+            gsub(/[^[:alnum:]_]+/, "__", p[4])
             if (p[5]) append("index", tolower(p[4]), "xref:"p[4]"["p[3]"]:: "p[5])
             append(p[1],"","[["p[4]"]]")
         }
@@ -72,7 +77,11 @@ match($0, com"(.*) HEAD([^ ]+) (.*); *(.*); *(.*)", p) {
 # Create an asciidoc index and anchor
 #             Sec        Title Index Explanation
 match($0, com"(.*) INDEX (.*); (.*); (.*)", p) {
-    if (p[4]) append("index", tolower(p[3]), "xref:"p[3]"["p[2]"]:: "p[4])
+    if (p[4])
+    {
+        gsub(/[^[:alnum:]_]+/, "__", p[3])
+        append("index", tolower(p[3]), "xref:"p[3]"["p[2]"]:: "p[4])
+    }
     append(p[1],"","[["p[3]"]]")
     next
 }