aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-11-05 16:47:17 +0100
committerGitHub <noreply@github.com>2020-11-05 16:47:17 +0100
commit8bbf57a2d0dfe8d8d6416a26f9ff1177c77e806b (patch)
tree8b2ff8ff1eabb2370ccf5931409f697e7d6f004f /application
parent47d15818502b11315b484131aaf67a3e3f441c5a (diff)
parent740b32b520e6b1723512c6f9b78cef6575b1725b (diff)
downloadShaarli-8bbf57a2d0dfe8d8d6416a26f9ff1177c77e806b.tar.gz
Shaarli-8bbf57a2d0dfe8d8d6416a26f9ff1177c77e806b.tar.zst
Shaarli-8bbf57a2d0dfe8d8d6416a26f9ff1177c77e806b.zip
Merge pull request #1620 from ArthurHoaro/feature/no-auto-link
Default formatter: add a setting to disable auto-linkification
Diffstat (limited to 'application')
-rw-r--r--application/bookmark/LinkUtils.php11
-rw-r--r--application/formatter/BookmarkDefaultFormatter.php7
2 files changed, 14 insertions, 4 deletions
diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php
index faf5dbfd..17c37979 100644
--- a/application/bookmark/LinkUtils.php
+++ b/application/bookmark/LinkUtils.php
@@ -138,12 +138,17 @@ function space2nbsp($text)
138 * 138 *
139 * @param string $description shaare's description. 139 * @param string $description shaare's description.
140 * @param string $indexUrl URL to Shaarli's index. 140 * @param string $indexUrl URL to Shaarli's index.
141 141 * @param bool $autolink Turn on/off automatic linkifications of URLs and hashtags
142 *
142 * @return string formatted description. 143 * @return string formatted description.
143 */ 144 */
144function format_description($description, $indexUrl = '') 145function format_description($description, $indexUrl = '', $autolink = true)
145{ 146{
146 return nl2br(space2nbsp(hashtag_autolink(text2clickable($description), $indexUrl))); 147 if ($autolink) {
148 $description = hashtag_autolink(text2clickable($description), $indexUrl);
149 }
150
151 return nl2br(space2nbsp($description));
147} 152}
148 153
149/** 154/**
diff --git a/application/formatter/BookmarkDefaultFormatter.php b/application/formatter/BookmarkDefaultFormatter.php
index d58a5e39..149a3eb9 100644
--- a/application/formatter/BookmarkDefaultFormatter.php
+++ b/application/formatter/BookmarkDefaultFormatter.php
@@ -46,8 +46,13 @@ class BookmarkDefaultFormatter extends BookmarkFormatter
46 $bookmark->getDescription() ?? '', 46 $bookmark->getDescription() ?? '',
47 $bookmark->getAdditionalContentEntry('search_highlight')['description'] ?? [] 47 $bookmark->getAdditionalContentEntry('search_highlight')['description'] ?? []
48 ); 48 );
49 $description = format_description(
50 escape($description),
51 $indexUrl,
52 $this->conf->get('formatter_settings.autolink', true)
53 );
49 54
50 return $this->replaceTokens(format_description(escape($description), $indexUrl)); 55 return $this->replaceTokens($description);
51 } 56 }
52 57
53 /** 58 /**