]> Sergey Matveev's repositories - zk.zsh.git/blobdiff - zk.zsh
Backlinks require square brackets now
[zk.zsh.git] / zk.zsh
diff --git a/zk.zsh b/zk.zsh
index 253c5029a33edca6f0e21d353cf50c89444f5033..81e032118715b6c02f0188f0e82948754c602504 100755 (executable)
--- a/zk.zsh
+++ b/zk.zsh
@@ -33,7 +33,10 @@ for p (${(k)pages}) {
     for w (`< $p`) {
         [[ $w =~ "\[(.*)\]" ]] || continue
         w=${match[1]}
-        [[ ${pages[$w]} ]] || continue
+        [[ ${pages[$w]} ]] || {
+            [[ $ZK_SHOW_MISSING ]] && print "Missing $w"
+            continue
+        }
         links[$p]="$w ${links[$p]}"
     }
 }
@@ -49,7 +52,6 @@ for p w (${(kv)backs}) {
     backs[$p]=${(j: :)ws}
 }
 
-autoload -U relative
 getrel() {
     # nearly the copy-paste of Functions/Misc/relative
     local dst=$2:a
@@ -71,7 +73,7 @@ getrel() {
 
 genhtml() {
     local page=$1
-    local data
+    local data p
     [[ $# -eq 1 ]] && data=`< $page` || data=$2
     data="${data//&/&amp;}"
     data="${data//</&lt;}"
@@ -79,7 +81,7 @@ genhtml() {
     for p (${(k)pages}) {
         [[ $p = index ]] && continue
         getrel $page $p
-        data="${data//${p}/<a href=\"${REPLY}.html\">$p</a>}"
+        data="${data//\[${p}\]/<a href=\"${REPLY}.html\">[$p]</a>}"
     }
     print "<\!DOCTYPE html>
 <html><head><title>$page (${pages[$page]})</title></head><body><pre>