Catch and exclude trailing punctuation while URL embedding

This commit is contained in:
Max Kostikov 2019-08-08 18:19:07 +02:00
parent 75a8b209f5
commit 2300581c93

View File

@ -205,6 +205,10 @@ function zidify_text($s) {
*/ */
function red_zrl_callback($matches) { function red_zrl_callback($matches) {
// Catch and exclude trailing punctuation
if (preg_match("/[.,;:!?)]*$/i", $matches[2], $pts))
$matches[2] = substr($matches[2], 0, strlen($matches[2])-strlen($pts[0]));
$zrl = is_matrix_url($matches[2]); $zrl = is_matrix_url($matches[2]);
$t = strip_zids($matches[2]); $t = strip_zids($matches[2]);
@ -215,10 +219,11 @@ function red_zrl_callback($matches) {
if($matches[1] === '#^') if($matches[1] === '#^')
$matches[1] = ''; $matches[1] = '';
if($zrl) if($zrl)
return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]'; return $matches[1] . '#^[zrl=' . $matches[2] . ']' . $matches[2] . '[/zrl]' . $pts[0];
return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]'; return $matches[1] . '#^[url=' . $matches[2] . ']' . $matches[2] . '[/url]' . $pts[0];
} }
/** /**