Update wikilink syntax
This prevents interference with markdown tables
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@
|
||||
onSelect: function (path, kind) {
|
||||
if (kind === 'folder') {
|
||||
promptDisplayText(sel, function (display) {
|
||||
insertAtCursor(display ? '[[' + path + '|' + display + ']]' : '[[' + path + ']]');
|
||||
insertAtCursor(display ? '[[' + path + '::' + display + ']]' : '[[' + path + ']]');
|
||||
});
|
||||
} else {
|
||||
var name = path.split('/').pop();
|
||||
|
||||
@@ -147,7 +147,7 @@ func validateAndNormalizeNewPath(raw string) (string, error) {
|
||||
}
|
||||
|
||||
// rewriteWikiLinks returns (newContent, changed). Any [[target]] or
|
||||
// [[target|display]] whose target equals oldPath or begins with oldPath+"/"
|
||||
// [[target::display]] whose target equals oldPath or begins with oldPath+"/"
|
||||
// has its target rewritten to the corresponding position under newPath.
|
||||
func rewriteWikiLinks(content []byte, oldPath, newPath string) ([]byte, bool) {
|
||||
changed := false
|
||||
@@ -170,7 +170,7 @@ func rewriteWikiLinks(content []byte, oldPath, newPath string) ([]byte, bool) {
|
||||
changed = true
|
||||
suffix := ""
|
||||
if len(parts[2]) > 0 {
|
||||
suffix = string(parts[2])
|
||||
suffix = "::" + string(parts[2])
|
||||
}
|
||||
return []byte("[[" + newTarget + suffix + "]]")
|
||||
})
|
||||
|
||||
+5
-4
@@ -16,14 +16,15 @@ import (
|
||||
"github.com/yuin/goldmark/util"
|
||||
)
|
||||
|
||||
// wikiLinkRe matches [[target]] and [[target|display]] anchored at the start
|
||||
// wikiLinkRe matches [[target]] and [[target::display]] anchored at the start
|
||||
// of the current inline reader. Target and display forbid newlines and
|
||||
// brackets; target additionally forbids the pipe separator.
|
||||
var wikiLinkRe = regexp.MustCompile(`^\[\[([^\[\]\|\n]+)(?:\|([^\[\]\n]+))?\]\]`)
|
||||
// brackets; the target is non-greedy so the first `::` separates target from
|
||||
// display when both are present.
|
||||
var wikiLinkRe = regexp.MustCompile(`^\[\[([^\[\]\n]+?)(?:::([^\[\]\n]+))?\]\]`)
|
||||
|
||||
// wikiLinkPattern matches wiki-link tokens anywhere in a markdown source.
|
||||
// Used by the move-endpoint rewriter; not by the goldmark parser.
|
||||
var wikiLinkPattern = regexp.MustCompile(`\[\[([^\[\]\n\|]+)(\|[^\[\]\n]+)?\]\]`)
|
||||
var wikiLinkPattern = regexp.MustCompile(`\[\[([^\[\]\n]+?)(?:::([^\[\]\n]+))?\]\]`)
|
||||
|
||||
// wikiLinkNode is the AST node produced by wikiLinkParser.
|
||||
type wikiLinkNode struct {
|
||||
|
||||
Reference in New Issue
Block a user