Allow stopping of URL detection at newlines via url_excluded_characters

Fixes #6122
This commit is contained in:
Kovid Goyal
2023-03-21 08:04:42 +05:30
parent 856fddec3c
commit f046884f23
4 changed files with 23 additions and 10 deletions

View File

@@ -469,10 +469,15 @@ are still clickable.
)
opt('url_excluded_characters', '',
ctype='!url_excluded_characters',
option_type='python_string', ctype='!url_excluded_characters',
long_text='''
Additional characters to be disallowed from URLs, when detecting URLs under the
mouse cursor. By default, all characters that are legal in URLs are allowed.
Additionally, newlines are allowed (but stripped). This is to accommodate
programs such as mutt that add hard line breaks even for continued lines.
:code:`\\\\n` can be added to this option to disable this behavior. Special
characters can be specified using backslash escapes, to specify a backslash use
a double backslash.
'''
)

View File

@@ -3,8 +3,8 @@
# isort: skip_file
import typing
from kitty.conf.utils import (
merge_dicts, positive_float, positive_int, to_bool, to_cmdline, to_color, to_color_or_none,
unit_float
merge_dicts, positive_float, positive_int, python_string, to_bool, to_cmdline, to_color,
to_color_or_none, unit_float
)
from kitty.options.utils import (
action_alias, active_tab_title_template, allow_hyperlinks, bell_on_tab, box_drawing_scale,
@@ -1302,7 +1302,7 @@ class Parser:
ans['url_color'] = to_color(val)
def url_excluded_characters(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['url_excluded_characters'] = str(val)
ans['url_excluded_characters'] = python_string(val)
def url_prefixes(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['url_prefixes'] = url_prefixes(val)