diff --git a/perlite/.js/perlite.js b/perlite/.js/perlite.js index bc1ed2e3..5f7cf30c 100644 --- a/perlite/.js/perlite.js +++ b/perlite/.js/perlite.js @@ -72,7 +72,7 @@ function unslugURL(targetPath) { function slugURL(targetPath) { encodedURI = decodeURIComponent(targetPath) - encodedURI = encodedURI.replaceAll('~', '%80') + encodedURI = encodedURI.replaceAll('~', '%2580') encodedURI = encodedURI.replaceAll('-', '~') encodedURI = encodedURI.replaceAll(' ', '-') @@ -1207,7 +1207,7 @@ function renderGraph(modal, path = "", filter_emptyNodes = false, show_tags = tr search(node.title); } else { - var glink = uriPath + node.title; + var glink = uriPath + slugURL(encodeURIComponent('/' + node.title)); window.open(glink, "_self"); } }); diff --git a/perlite/.src/PerliteCanvas.php b/perlite/.src/PerliteCanvas.php index beedf373..9edbe753 100644 --- a/perlite/.src/PerliteCanvas.php +++ b/perlite/.src/PerliteCanvas.php @@ -1,7 +1,7 @@ uriPath . $slug; + return $this->uriPath . PerliteParsedown::slugPath(ltrim($path, '/')); } // direct url of a vault file, served by the webserver diff --git a/perlite/.src/PerliteParsedown.php b/perlite/.src/PerliteParsedown.php index dc3ffa7a..0c5405e1 100644 --- a/perlite/.src/PerliteParsedown.php +++ b/perlite/.src/PerliteParsedown.php @@ -1,7 +1,7 @@ "%2580" (decodes to "%80"), "-" -> "~", " " -> "-" + public static function slugPath(string $path): string + { + $path = str_replace('~', '%2580', $path); + $path = str_replace('-', '~', $path); + $path = str_replace(' ', '-', $path); + + return $path; + } + # # YAML Front Matter / Obsidian Properties # See: https://help.obsidian.md/Editing+and+formatting/Properties @@ -1595,9 +1606,7 @@ protected function inlineInternalLink($Excerpt) if ($openNewTab == false) { $urlPath = str_replace('&', '&', $urlPath); $urlPath = str_replace('%23', '#', $urlPath); - $urlPath = str_replace('~', '%80', $urlPath); - $urlPath = str_replace('-', '~', $urlPath); - $urlPath = str_replace(' ', '-', $urlPath); + $urlPath = self::slugPath($urlPath); } return array(