X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=index.php;h=7ae8e478efa5eac7432ab39c0d68dd2e4b524cd4;hb=f60062deb36b708d1b28b0e264957562b06964f3;hp=93454eceddd5abfb2dd306e4bb90420805fb4cc7;hpb=26a62311e466992b321019dbca9521ee36e19ada;p=mdref%2Fmdref diff --git a/index.php b/index.php index 93454ec..7ae8e47 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("