Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions perlite/.js/perlite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ', '-')

Expand Down Expand Up @@ -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");
}
});
Expand Down
9 changes: 2 additions & 7 deletions perlite/.src/PerliteCanvas.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*!
* Perlite v1.6.2 (https://github.com/secure-77/Perlite)
* Perlite v1.6.3 (https://github.com/secure-77/Perlite)
* Author: sec77 (https://secure77.de)
* Licensed under MIT (https://github.com/secure-77/Perlite/blob/main/LICENSE)
*/
Expand Down Expand Up @@ -522,12 +522,7 @@ protected function dirOf($path)
// perlite url of a note (same slug format as PerliteParsedown internal links)
protected function noteUrl($path)
{
$slug = ltrim($path, '/');
$slug = str_replace('~', '%80', $slug);
$slug = str_replace('-', '~', $slug);
$slug = str_replace(' ', '-', $slug);

return $this->uriPath . $slug;
return $this->uriPath . PerliteParsedown::slugPath(ltrim($path, '/'));
}

// direct url of a vault file, served by the webserver
Expand Down
17 changes: 13 additions & 4 deletions perlite/.src/PerliteParsedown.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*!
* Perlite v1.6.2 (https://github.com/secure-77/Perlite)
* Perlite v1.6.3 (https://github.com/secure-77/Perlite)
* Author: sec77 (https://secure77.de)
* Licensed under MIT (https://github.com/secure-77/Perlite/blob/main/LICENSE)
*/
Expand Down Expand Up @@ -123,6 +123,17 @@ function text($text)
return $markup;
}

# pretty url slug of a vault path, reversed by unslugURL() in perlite.js
# "~" -> "%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
Expand Down Expand Up @@ -1595,9 +1606,7 @@ protected function inlineInternalLink($Excerpt)
if ($openNewTab == false) {
$urlPath = str_replace('&amp;', '&', $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(
Expand Down
Loading