Skip to content

Commit f8930d1

Browse files
committed
home/wezterm: try to fix capturing markdown link
1 parent 72e6ef6 commit f8930d1

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

home/dot_config/wezterm/wezterm.lua

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,47 @@ if is_windows then
7373
dev_domain = sshmux_domain
7474
end
7575

76-
local config = {}
76+
local config = wezterm.config_builder()
77+
78+
-- [default hyperlink_rules is wrong for Markdown link format · Issue #3803 · wezterm/wezterm](https://github.com/wezterm/wezterm/issues/3803)
79+
config.hyperlink_rules = {
80+
-- Matches: a URL in parens: (URL)
81+
-- Markdown: [text](URL title)
82+
{
83+
regex = '\\((\\w+://[^\\s\\)]+)(?:\\s+[^\\)]*)?\\)',
84+
format = '$1',
85+
highlight = 1,
86+
},
87+
-- Matches: a URL in brackets: [URL]
88+
{
89+
regex = '\\[(\\w+://\\S+?)\\]',
90+
format = '$1',
91+
highlight = 1,
92+
},
93+
-- Matches: a URL in curly braces: {URL}
94+
{
95+
regex = '\\{(\\w+://\\S+?)\\}',
96+
format = '$1',
97+
highlight = 1,
98+
},
99+
-- Matches: a URL in angle brackets: <URL>
100+
{
101+
regex = '<(\\w+://\\S+?)>',
102+
format = '$1',
103+
highlight = 1,
104+
},
105+
-- Then handle URLs not wrapped in brackets
106+
-- regex = '\\b\\w+://\\S+[)/a-zA-Z0-9-]+',
107+
{
108+
regex = '(?<![\\(\\{\\[<])\\b\\w+://\\S+',
109+
format = '$0',
110+
},
111+
-- implicit mailto link
112+
{
113+
regex = '\\b\\w+@[\\w-]+(\\.[\\w-]+)+\\b',
114+
format = 'mailto:$0',
115+
},
116+
}
77117

78118
config.tls_clients = {}
79119

0 commit comments

Comments
 (0)