X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=index.php;h=5c4b909b5057fe201b23b09978d73c0a785222dd;hb=4199b3fd65d963057c82c1541df6e2f786e6bd9d;hp=93454eceddd5abfb2dd306e4bb90420805fb4cc7;hpb=46d9b15be0fb214993462c7fa1187896b949d00a;p=mdref%2Fmdref diff --git a/index.php b/index.php index 93454ec..5c4b909 100644 --- a/index.php +++ b/index.php @@ -62,7 +62,25 @@ function head($file, $lines = 1) { return $ld; } -function ns($file) { +function ns($path) { + $ns = ""; + $parts = explode("/", $path); + $upper = ctype_upper($path[0]); + for ($i = 0; $i < count($parts); ++$i) { + if (!strlen($parts[$i]) || $parts[$i] === ".") { + continue; + } + if (strlen($ns)) { + if ($upper && !ctype_upper($parts[$i][0])) { + $ns .= "::"; + } else { + $ns .= "\\"; + } + } + $ns .= $parts[$i]; + $upper = ctype_upper($parts[$i][0]); + } + return $ns; return str_replace("/", "\\", str_replace("//", "/", trim($file, "/."))); } @@ -73,9 +91,9 @@ function urlpath($dir, $file) { function ls($dir) { $dir = rtrim(is_dir($dir) ? $dir : dirname($dir) ."/". basename($dir, ".md"), "/"); printf("