mirror of
https://github.com/mickael-menu/zk
synced 2024-11-03 23:15:49 +00:00
Fix unicode support in wiki links (#49)
This commit is contained in:
parent
729dbe9760
commit
5b877dd953
@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* [#16](https://github.com/mickael-menu/zk/issues/16) Links with section anchors, e.g. `[[filename#section]]`.
|
* [#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
|
## 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):
|
* [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.
|
* 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).
|
* 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]((`.
|
* 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).
|
* Customize the format of `fzf`'s lines [with your own template](docs/tool-fzf.md).
|
||||||
```toml
|
```toml
|
||||||
@ -51,7 +52,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
* Interactive wizard for the `zk init` command.
|
* Interactive wizard for the `zk init` command.
|
||||||
* An experimental Language Server for LSP-compatible editors:
|
* 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).
|
* Auto-complete [hashtags and colon-separated tags](docs/tags.md).
|
||||||
* Preview the content of a note when hovering a link.
|
* Preview the content of a note when hovering a link.
|
||||||
* Navigate in your notes by following internal links.
|
* 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.
|
* 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 `{{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.
|
* 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
|
### Changed
|
||||||
|
|
||||||
|
@ -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
|
endPos = 0 // Last position of the link in the line
|
||||||
)
|
)
|
||||||
|
|
||||||
appendChar := func(c byte) {
|
appendRune := func(c rune) {
|
||||||
if parsingLabel {
|
if parsingLabel {
|
||||||
label += string(c)
|
label += string(c)
|
||||||
} else {
|
} 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
|
endPos = i
|
||||||
|
|
||||||
if closed {
|
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.
|
// We add them to the HREF and reset the count.
|
||||||
if closerCharCount > 0 {
|
if closerCharCount > 0 {
|
||||||
for i := 0; i < closerCharCount; i++ {
|
for i := 0; i < closerCharCount; i++ {
|
||||||
appendChar(']')
|
appendRune(']')
|
||||||
}
|
}
|
||||||
closerCharCount = 0
|
closerCharCount = 0
|
||||||
}
|
}
|
||||||
appendChar(char)
|
appendRune(char)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !closed || len(href) == 0 {
|
if !closed || len(href) == 0 {
|
||||||
|
@ -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]].
|
A [[Wiki link]] is surrounded by [[2-brackets | two brackets]].
|
||||||
|
|
||||||
|
[[lien accentué]]
|
||||||
|
|
||||||
It can contain [[esca]\]ped \[chara\\cters]].
|
It can contain [[esca]\]ped \[chara\\cters]].
|
||||||
|
|
||||||
A [[[Folgezettel link]]] is surrounded by three brackets.
|
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,
|
SnippetStart: 288,
|
||||||
SnippetEnd: 351,
|
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`,
|
Title: `esca]]ped [chara\cters`,
|
||||||
Href: `esca]]ped [chara\cters`,
|
Href: `esca]]ped [chara\cters`,
|
||||||
IsExternal: false,
|
IsExternal: false,
|
||||||
Rels: []core.LinkRelation{},
|
Rels: []core.LinkRelation{},
|
||||||
Snippet: `It can contain [[esca]\]ped \[chara\\cters]].`,
|
Snippet: `It can contain [[esca]\]ped \[chara\\cters]].`,
|
||||||
SnippetStart: 353,
|
SnippetStart: 373,
|
||||||
SnippetEnd: 398,
|
SnippetEnd: 418,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Title: "Folgezettel link",
|
Title: "Folgezettel link",
|
||||||
@ -476,8 +487,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel-
|
|||||||
IsExternal: false,
|
IsExternal: false,
|
||||||
Rels: core.LinkRels("down"),
|
Rels: core.LinkRels("down"),
|
||||||
Snippet: "A [[[Folgezettel link]]] is surrounded by three brackets.",
|
Snippet: "A [[[Folgezettel link]]] is surrounded by three brackets.",
|
||||||
SnippetStart: 400,
|
SnippetStart: 420,
|
||||||
SnippetEnd: 457,
|
SnippetEnd: 477,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Title: "trailing hash",
|
Title: "trailing hash",
|
||||||
@ -485,8 +496,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel-
|
|||||||
IsExternal: false,
|
IsExternal: false,
|
||||||
Rels: core.LinkRels("down"),
|
Rels: core.LinkRels("down"),
|
||||||
Snippet: "Neuron also supports a [[trailing hash]]# for Folgezettel links.",
|
Snippet: "Neuron also supports a [[trailing hash]]# for Folgezettel links.",
|
||||||
SnippetStart: 459,
|
SnippetStart: 479,
|
||||||
SnippetEnd: 523,
|
SnippetEnd: 543,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Title: "leading hash",
|
Title: "leading hash",
|
||||||
@ -494,8 +505,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel-
|
|||||||
IsExternal: false,
|
IsExternal: false,
|
||||||
Rels: core.LinkRels("up"),
|
Rels: core.LinkRels("up"),
|
||||||
Snippet: "A #[[leading hash]] is used for #uplinks.",
|
Snippet: "A #[[leading hash]] is used for #uplinks.",
|
||||||
SnippetStart: 525,
|
SnippetStart: 545,
|
||||||
SnippetEnd: 566,
|
SnippetEnd: 586,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Title: "Trailing link",
|
Title: "Trailing link",
|
||||||
@ -503,8 +514,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel-
|
|||||||
IsExternal: false,
|
IsExternal: false,
|
||||||
Rels: core.LinkRels("down"),
|
Rels: core.LinkRels("down"),
|
||||||
Snippet: "Neuron links with titles: [[trailing|Trailing link]]# #[[leading | Leading link]]",
|
Snippet: "Neuron links with titles: [[trailing|Trailing link]]# #[[leading | Leading link]]",
|
||||||
SnippetStart: 568,
|
SnippetStart: 588,
|
||||||
SnippetEnd: 650,
|
SnippetEnd: 670,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Title: "Leading link",
|
Title: "Leading link",
|
||||||
@ -512,8 +523,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel-
|
|||||||
IsExternal: false,
|
IsExternal: false,
|
||||||
Rels: core.LinkRels("up"),
|
Rels: core.LinkRels("up"),
|
||||||
Snippet: "Neuron links with titles: [[trailing|Trailing link]]# #[[leading | Leading link]]",
|
Snippet: "Neuron links with titles: [[trailing|Trailing link]]# #[[leading | Leading link]]",
|
||||||
SnippetStart: 568,
|
SnippetStart: 588,
|
||||||
SnippetEnd: 650,
|
SnippetEnd: 670,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Title: "External links",
|
Title: "External links",
|
||||||
@ -521,8 +532,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel-
|
|||||||
Rels: []core.LinkRelation{},
|
Rels: []core.LinkRelation{},
|
||||||
IsExternal: true,
|
IsExternal: true,
|
||||||
Snippet: `[External links](http://example.com) are marked [as such](ftp://domain).`,
|
Snippet: `[External links](http://example.com) are marked [as such](ftp://domain).`,
|
||||||
SnippetStart: 652,
|
SnippetStart: 672,
|
||||||
SnippetEnd: 724,
|
SnippetEnd: 744,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Title: "as such",
|
Title: "as such",
|
||||||
@ -530,8 +541,8 @@ A link can have [one relation](one "rel-1") or [several relations](several "rel-
|
|||||||
Rels: []core.LinkRelation{},
|
Rels: []core.LinkRelation{},
|
||||||
IsExternal: true,
|
IsExternal: true,
|
||||||
Snippet: `[External links](http://example.com) are marked [as such](ftp://domain).`,
|
Snippet: `[External links](http://example.com) are marked [as such](ftp://domain).`,
|
||||||
SnippetStart: 652,
|
SnippetStart: 672,
|
||||||
SnippetEnd: 724,
|
SnippetEnd: 744,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user