From: Michael Wallner Date: Thu, 27 Jan 2022 15:36:59 +0000 (+0100) Subject: fix some leftovers X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=50ac575b6c1486de5f9561eb92d010f07bf905e7;p=mdref%2Fmdref fix some leftovers --- diff --git a/VERSION b/VERSION index cd5ac03..9f55b2c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0 +3.0 diff --git a/mdref/Formatter.php b/mdref/Formatter.php index 95a276f..b103a10 100644 --- a/mdref/Formatter.php +++ b/mdref/Formatter.php @@ -60,7 +60,7 @@ class Formatter { * @return string the simplified slug */ public function formatSlug(string $string) : string { - return preg_replace("/[^\$[:alnum:]:._-]+/", ".", $string); + return preg_replace("/[^\$[:alnum:]:._-]+/", ".", trim($string, "/ \r\n\t")); } /** diff --git a/mdref/Reference.php b/mdref/Reference.php index 4197de1..4ff5f90 100644 --- a/mdref/Reference.php +++ b/mdref/Reference.php @@ -70,11 +70,11 @@ class Reference implements IteratorAggregate { * @param string $anchor * @return string */ - public function formatAnchor(string $anchor, string $location = null) : string { + public function formatAnchor(string $anchor) : string { if (is_numeric($anchor)) { return "L$anchor"; } - return preg_replace("/[^[:alnum:]\.:_]/", ".", $anchor); + return $this->fmt->formatSlug($anchor); } /** @@ -82,8 +82,8 @@ class Reference implements IteratorAggregate { * @return string * @throws \Exception, Exception */ - public function formatString(string $string, string $location = null) : string { - return $this->fmt->formatString($string, $location); + public function formatString(string $string) : string { + return $this->fmt->formatString($string); } /** @@ -91,7 +91,7 @@ class Reference implements IteratorAggregate { * @return string * @throws \Exception, Exception */ - public function formatFile(string $file, string $location = null) : string { - return $this->fmt->formatFile($file, $location); + public function formatFile(string $file) : string { + return $this->fmt->formatFile($file); } }