diff --git a/php/utils/markdown.php b/php/utils/markdown.php index 4611b8c..2db0550 100644 --- a/php/utils/markdown.php +++ b/php/utils/markdown.php @@ -274,7 +274,7 @@ class MarkdownEntity { private array $props; public function renderStart(): string { - global $REPOSITORY_CANONICAL_URL_FILES; + global $REPOSITORY_CANONICAL_URL_FILES, $SITE_CANONICAL_URL; $type = $this->type; switch ($type) { @@ -283,6 +283,10 @@ class MarkdownEntity { if (!str_starts_with($href, "#") && !str_contains($href, "://")) { $href = "$REPOSITORY_CANONICAL_URL_FILES/$href"; } + remove_prefix($href, $SITE_CANONICAL_URL); + if (empty($href)) { + $href = "/"; + } return "\n"; default: return "\n<$type>"; }