Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support link completion with non-english filename (I suggest solution) #717

Open
Jaehaks opened this issue Sep 19, 2024 · 0 comments
Open

Comments

@Jaehaks
Copy link

Jaehaks commented Sep 19, 2024

🚀 The feature, motivation and pitch

Problem

util.urlencode() function in lua/obsidian/util.lua changes non-english filename to hex.

Reason

because it uses url = url:gsub("([^/%w _%%%-%.~])", char_to_hex) in this funciton

util.urlencode = function(str, opts)
  opts = opts or {}
  local url = str
  url = url:gsub("\n", "\r\n")
  url = url:gsub("([^/%w _%%%-%.~])", char_to_hex)
  if not opts.keep_path_sep then
    url = url:gsub("/", char_to_hex)
  end
  
  url = url:gsub(" ", "%%20")
  return url
end

Suggestion

I think it would be better to limit what it wants to convert rather than what it doesn't want to convert.
It changes any word which is non-english filename
I tested making and linking file whose filename has puntuation characters.

The result is below

  1. (), [], {},. , $, :, ?, *, ", <>, | : these are impossible to use
  2. +, ^, !, &, ;, =, @, comma : these are possible to use

so I suggest use this line instead of current line

url = url:gsub("([%(%)%*%?%[%]%$\"':<>|\\`{}])", char_to_hex)

I am not good at to use regex, so it is the best what do I best.
I hope you can change it more precise.

Alternatives

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant