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

link doesn't recognize non-english heading #718

Closed
Jaehaks opened this issue Sep 19, 2024 · 1 comment
Closed

link doesn't recognize non-english heading #718

Jaehaks opened this issue Sep 19, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Jaehaks
Copy link

Jaehaks commented Sep 19, 2024

πŸ› Describe the bug

When I make link which has heading, it is ok to add english heading like [test](ν…ŒμŠ€νŠΈ/ν…ŒμŠ€νŠΈ2.md#test)
If the heading has non-english character, the link name shows the heading name properly but link url doesn't.
It show '--' like this

image

I find that the result doesn't have url if the heading is non-english.

    ---@param res obsidian.ResolveLinkResult
    local function follow_link(res)
      if res.url ~= nil then     -- if heading is non-english, res.url == nil
        if self.opts.follow_url_func ~= nil then
          self.opts.follow_url_func(res.url)
        else
          log.warn "This looks like a URL. You can customize the behavior of URLs with the 'follow_url_func' option."
        end

Unfortunately, I cannot find where the follow_link_async() function is called and what character is added to results

Could you fix this?

Config

local obsidian = require('obsidian')
obsidian.setup({
workspaces = { -- this directory must exist
	{
		name = 'Personal',
		path = paths.obsidian.personal
	},
},
mappings = {}, -- disable default keymapping
new_notes_location = 'current_dir',
preferred_link_style = 'markdown',
follow_url_func = function (url) -- command for follow url
	vim.fn.system('start ' .. url)
end,
attachments = {
	confirm_img_paste = true, -- show confirm message when paste
	img_name_func = function () -- download clipboard image to filename folder
		return string.format("%s\\%s-", vim.fn.expand('%:p:r'), os.date('%y%m%d'))
	end,
	img_text_func = function (client, path)
		path = path:relative_to(vim.fn.expand('%:p:h'))
		return string.format("![%s](%s)", path.name, path)
	end
},
ui = {
	enable = false, -- use markdown.nvim as renderer
	checkboxes = {
		[" "] = { char = "", hl_group = 'ObsidianTodo'},
		["x"] = { char = "σ°„²", hl_group = 'ObsidianDone'},
		["-"] = { char = "󱋭"},
	}
},
note_id_func = function (title) -- set note id automatically when :ObsidianNew
	if title == nil then 
		title = 'NewFile'
	else
		title = title:gsub(' ','_')
	end
	return title
end,
})

Environment

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info
Obsidian.nvim v3.9.0 (707329c840fca5b2e9b25a112804cddbe5aab669)                                                             Status:                                                                                                                       β€’ buffer directory: C:/Users/USER/Obsidian_Nvim/Personal/ν…ŒμŠ€νŠΈ                                                             β€’ working directory: C:/Users/USER/.config/nvim/lua/jaehak/plugins                                                        Workspaces:                                                                                                                   βœ“ active workspace: Workspace(name='Personal', path='C:/Users/USER/Obsidian_Nvim/Personal', root='C:/Users/USER/Obsidian_Nvim/Personal')                                                                                                              Dependencies:                                                                                                                 βœ“ plenary.nvim: ec289423a1693aeae6cd0d503bac2856af74edaa                                                                    βœ“ nvim-cmp: ae644feb7b67bf1ce4260c231d1d4300b19c6f30                                                                        βœ“ telescope.nvim: 927c10f748e49c543b2d544c321a1245302ff324                                                                Integrations:                                                                                                                 βœ“ picker: TelescopePicker()                                                                                                 βœ“ completion: enabled (nvim-cmp) βœ— refs, βœ— tags, βœ— new                                                                        all sources:                                                                                                                  β€’ luasnip                                                                                                                   β€’ nvim_lsp                                                                                                                  β€’ buffer                                                                                                                    β€’ dictionary                                                                                                                β€’ path                                                                                                                Tools:                                                                                                                        βœ“ rg: ripgrep 14.1.0 (rev e50df40a19)                                                                                     Environment:                                                                                                                  β€’ operating system: Windows                                                                                               Config:                                                                                                                       β€’ notes_subdir: nil    
@Jaehaks Jaehaks added the bug Something isn't working label Sep 19, 2024
@Jaehaks
Copy link
Author

Jaehaks commented Sep 19, 2024

I found the solution at PR #679
Just changed like below code

In lua/obsidian/utils.lua

at 1128

util.ANCHOR_LINK_PATTERN = "#[%w%d\128-\255][^#]*"

at 1241

anchor = string.gsub(anchor, "[^#%w\128-\255_-]", "")

@Jaehaks Jaehaks closed this as completed Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant