diff --git a/CHANGELOG.md b/CHANGELOG.md index 18f4f24..b24ae06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. ### Fixed * [#16](https://github.com/mickael-menu/zk/issues/16) Links with section anchors, e.g. `[[filename#section]]`. +* Unicode support in wiki links. If you use accents or ideograms, please run `zk index --force` after upgrading to fix your index. ## 0.5.0 @@ -26,7 +27,7 @@ All notable changes to this project will be documented in this file. * [Editor integration through LSP](https://github.com/mickael-menu/zk/issues/22): * New code actions to create a note using the current selection as title. * Custom commands to [run `new` and `index` from your editor](docs/editors-integration.md#custom-commands). - * Diagnostics to [report dead links or wiki-link titles](docs/config-lsp.md). + * Diagnostics to [report dead links or wiki link titles](docs/config-lsp.md). * Auto-complete only the path of a Markdown link by typing `[custom title]((`. * Customize the format of `fzf`'s lines [with your own template](docs/tool-fzf.md). ```toml @@ -51,7 +52,7 @@ All notable changes to this project will be documented in this file. * Interactive wizard for the `zk init` command. * An experimental Language Server for LSP-compatible editors: - * Auto-complete Markdown links with `[[` (setup wiki-links in the [note formats configuration](docs/note-format.md)) + * Auto-complete Markdown links with `[[` (setup wiki links in the [note formats configuration](docs/note-format.md)) * Auto-complete [hashtags and colon-separated tags](docs/tags.md). * Preview the content of a note when hovering a link. * Navigate in your notes by following internal links. @@ -62,7 +63,7 @@ All notable changes to this project will be documented in this file. * Generating links to notes. * Use the `{{link}}` template variable when [formatting notes](docs/template-format.md) to print a link to the note, relative to the working directory. * Use the `{{format-link path title}}` template helper to render a custom link. - * Customize the link format from the [note formats settings](docs/note-format.md). You can for example choose regular Markdown links, Wiki-links or a custom format. + * Customize the link format from the [note formats settings](docs/note-format.md). You can for example choose regular Markdown links, wiki links or a custom format. ### Changed diff --git a/internal/adapter/markdown/extensions/wikilink.go b/internal/adapter/markdown/extensions/wikilink.go index 4198fa2..5177712 100644 --- a/internal/adapter/markdown/extensions/wikilink.go +++ b/internal/adapter/markdown/extensions/wikilink.go @@ -51,7 +51,7 @@ func (p *wlParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) endPos = 0 // Last position of the link in the line ) - appendChar := func(c byte) { + appendRune := func(c rune) { if parsingLabel { label += string(c) } else { @@ -59,7 +59,7 @@ func (p *wlParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) } } - for i, char := range line { + for i, char := range string(line) { endPos = i if closed { @@ -116,11 +116,11 @@ func (p *wlParser) Parse(parent ast.Node, block text.Reader, pc parser.Context) // We add them to the HREF and reset the count. if closerCharCount > 0 { for i := 0; i < closerCharCount; i++ { - appendChar(']') + appendRune(']') } closerCharCount = 0 } - appendChar(char) + appendRune(char) } if !closed || len(href) == 0 { diff --git a/internal/adapter/markdown/markdown_test.go b/internal/adapter/markdown/markdown_test.go index fa0f5fe..1d827a5 100644 --- a/internal/adapter/markdown/markdown_test.go +++ b/internal/adapter/markdown/markdown_test.go @@ -364,6 +364,8 @@ An https://inline-link.com and http://another-inline-link.com. A [[Wiki link]] is surrounded by [[2-brackets | two brackets]]. +[[lien accentué]] + It can contain [[esca]\]ped \[chara\\cters]]. A [[[Folgezettel link]]] is surrounded by three brackets. @@ -461,14 +463,23 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- SnippetStart: 288, SnippetEnd: 351, }, + { + Title: "lien accentué", + Href: "lien accentué", + IsExternal: false, + Rels: []core.LinkRelation{}, + Snippet: "[[lien accentué]]", + SnippetStart: 353, + SnippetEnd: 371, + }, { Title: `esca]]ped [chara\cters`, Href: `esca]]ped [chara\cters`, IsExternal: false, Rels: []core.LinkRelation{}, Snippet: `It can contain [[esca]\]ped \[chara\\cters]].`, - SnippetStart: 353, - SnippetEnd: 398, + SnippetStart: 373, + SnippetEnd: 418, }, { Title: "Folgezettel link", @@ -476,8 +487,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- IsExternal: false, Rels: core.LinkRels("down"), Snippet: "A [[[Folgezettel link]]] is surrounded by three brackets.", - SnippetStart: 400, - SnippetEnd: 457, + SnippetStart: 420, + SnippetEnd: 477, }, { Title: "trailing hash", @@ -485,8 +496,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- IsExternal: false, Rels: core.LinkRels("down"), Snippet: "Neuron also supports a [[trailing hash]]# for Folgezettel links.", - SnippetStart: 459, - SnippetEnd: 523, + SnippetStart: 479, + SnippetEnd: 543, }, { Title: "leading hash", @@ -494,8 +505,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- IsExternal: false, Rels: core.LinkRels("up"), Snippet: "A #[[leading hash]] is used for #uplinks.", - SnippetStart: 525, - SnippetEnd: 566, + SnippetStart: 545, + SnippetEnd: 586, }, { Title: "Trailing link", @@ -503,8 +514,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- IsExternal: false, Rels: core.LinkRels("down"), Snippet: "Neuron links with titles: [[trailing|Trailing link]]# #[[leading | Leading link]]", - SnippetStart: 568, - SnippetEnd: 650, + SnippetStart: 588, + SnippetEnd: 670, }, { Title: "Leading link", @@ -512,8 +523,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- IsExternal: false, Rels: core.LinkRels("up"), Snippet: "Neuron links with titles: [[trailing|Trailing link]]# #[[leading | Leading link]]", - SnippetStart: 568, - SnippetEnd: 650, + SnippetStart: 588, + SnippetEnd: 670, }, { Title: "External links", @@ -521,8 +532,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- Rels: []core.LinkRelation{}, IsExternal: true, Snippet: `[External links](http://example.com) are marked [as such](ftp://domain).`, - SnippetStart: 652, - SnippetEnd: 724, + SnippetStart: 672, + SnippetEnd: 744, }, { Title: "as such", @@ -530,8 +541,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel- Rels: []core.LinkRelation{}, IsExternal: true, Snippet: `[External links](http://example.com) are marked [as such](ftp://domain).`, - SnippetStart: 652, - SnippetEnd: 724, + SnippetStart: 672, + SnippetEnd: 744, }, }) }