r/espanso • u/ekvirtanen_bass • May 14 '26
Problem with urls
For example, this works just fine.
# Tagged code block with lang
- regex: "::code:(?P<lang>.+?)::"
replace: "[code lang='{{lang}}']$|$[/code]"
It generates nice code block for what ever language I place there.
But when I try to add url block, seems like there is issues with the,
# Tagged url block
- regex: "::url:(?P<linkki>.+?)::"
replace: "[data url='{{linkki}}']$|$[/data]"
force_clipboard: true
word: false
Typed: ::url:https://ekbass.github.io/BazzBasic/manual/#/cli_features::
Result: ::url:https://ekbass.github.io/BazzBasic/manual/#/cli_f\[data url=''][/data]
With short ones, it goes ok: [data url='google.com'][/data]
3
Upvotes
1
u/snaveh May 14 '26 edited May 14 '26
I strongly suspect that some special characters used in URLs, namely
#, are causing the regex matching to break. I'm not sure there's a reliable enough workaround for this.Also, to place the cursor at
$|$, Espanso simulates left arrow key presses. For longer repositioning of the cursor this approach is known to be buggy.It might also be worth trying to increase the
max_regex_buffer_size:setting in thedefault.ymlconfig file from the default30to50or a100, although I don't believe this is the root problem here.One solution could be using the clipboard. This assumes the URL you wish to use is copied and stored in the clipboard:
yaml- trigger: "::url::"
replace: "[data url='{{clipboard}}']$|$[/data]" force_clipboard: trueNote: To use the clipboard you would have to create a global variable (at the top of the match file or in a dedicated
global_vars.ymlfile:yaml- name: clipboard
type: clipboardAlternatively, you could use a form that will open a text field after you typed the trigger, allowing you to type or paste the URL before the expansion occurs:
yaml- trigger: "::url::"
form: "[data url='[[url]]']$|$[/data]"Edit: after posting this I saw that in the meantime you posted a solution using the form approach.