|
|
@ -1,4 +1,4 @@
|
|
|
|
package wikilink_test
|
|
|
|
package markdown_test
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"testing"
|
|
|
@ -6,193 +6,193 @@ import (
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"go.uber.org/zap/zapcore"
|
|
|
|
"go.uber.org/zap/zapcore"
|
|
|
|
|
|
|
|
|
|
|
|
"code.ndumas.com/ndumas/wikilink-parser"
|
|
|
|
"code.ndumas.com/ndumas/obsidian-markdown"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var SingleWikilink = []tc{
|
|
|
|
var SingleWikilink = []tc{
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink",
|
|
|
|
name: "wikilink",
|
|
|
|
in: "[[wikilink]]",
|
|
|
|
in: "[[wikilink]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink|display name",
|
|
|
|
name: "wikilink|display name",
|
|
|
|
in: "[[wikilink|display name]]",
|
|
|
|
in: "[[wikilink|display name]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "display name"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "display name"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink|display name|second pipe",
|
|
|
|
name: "wikilink|display name|second pipe",
|
|
|
|
in: "[[wikilink|display name|second pipe]]",
|
|
|
|
in: "[[wikilink|display name|second pipe]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "display name"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "display name"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink with numeric alias|420|second pipe",
|
|
|
|
name: "wikilink with numeric alias|420|second pipe",
|
|
|
|
in: "[[wikilink|420|second pipe]]",
|
|
|
|
in: "[[wikilink|420|second pipe]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "420"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "420"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink with spaces in filename",
|
|
|
|
name: "wikilink with spaces in filename",
|
|
|
|
in: "[[wikilink spaces]]",
|
|
|
|
in: "[[wikilink spaces]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink spaces"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink spaces"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "#heading",
|
|
|
|
name: "#heading",
|
|
|
|
in: "[[#heading]]",
|
|
|
|
in: "[[#heading]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: ""},
|
|
|
|
{Typ: markdown.LexIdent, Val: ""},
|
|
|
|
{Typ: wikilink.LexHeading, Val: "#"},
|
|
|
|
{Typ: markdown.LexHeading, Val: "#"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "heading"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "heading"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink#heading",
|
|
|
|
name: "wikilink#heading",
|
|
|
|
in: "[[wikilink#heading]]",
|
|
|
|
in: "[[wikilink#heading]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexHeading, Val: "#"},
|
|
|
|
{Typ: markdown.LexHeading, Val: "#"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "heading"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "heading"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink#heading|display name",
|
|
|
|
name: "wikilink#heading|display name",
|
|
|
|
in: "[[wikilink#heading|display name]]",
|
|
|
|
in: "[[wikilink#heading|display name]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexHeading, Val: "#"},
|
|
|
|
{Typ: markdown.LexHeading, Val: "#"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "heading"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "heading"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "display name"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "display name"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink#heading|display name|second pipe",
|
|
|
|
name: "wikilink#heading|display name|second pipe",
|
|
|
|
in: "[[wikilink#heading|display name|second pipe]]",
|
|
|
|
in: "[[wikilink#heading|display name|second pipe]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexHeading, Val: "#"},
|
|
|
|
{Typ: markdown.LexHeading, Val: "#"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "heading"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "heading"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "display name"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "display name"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink with numeric aliases#heading|420|display name",
|
|
|
|
name: "wikilink with numeric aliases#heading|420|display name",
|
|
|
|
in: "[[wikilink#heading|420|second pipe]]",
|
|
|
|
in: "[[wikilink#heading|420|second pipe]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexHeading, Val: "#"},
|
|
|
|
{Typ: markdown.LexHeading, Val: "#"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "heading"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "heading"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "420"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "420"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "#^blockRef",
|
|
|
|
name: "#^blockRef",
|
|
|
|
in: "[[#^blockRef]]",
|
|
|
|
in: "[[#^blockRef]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: ""},
|
|
|
|
{Typ: markdown.LexIdent, Val: ""},
|
|
|
|
{Typ: wikilink.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: markdown.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink#^blockRef",
|
|
|
|
name: "wikilink#^blockRef",
|
|
|
|
in: "[[wikilink#^blockRef]]",
|
|
|
|
in: "[[wikilink#^blockRef]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: markdown.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink#^blockRef|display name",
|
|
|
|
name: "wikilink#^blockRef|display name",
|
|
|
|
in: "[[wikilink#^blockRef|display name]]",
|
|
|
|
in: "[[wikilink#^blockRef|display name]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: markdown.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "display name"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "display name"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink#^blockRef|display name|second pipe",
|
|
|
|
name: "wikilink#^blockRef|display name|second pipe",
|
|
|
|
in: "[[wikilink#^blockRef|display name|second pipe]]",
|
|
|
|
in: "[[wikilink#^blockRef|display name|second pipe]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: markdown.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "display name"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "display name"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: "wikilink with numeric aliases#^blockRef|420|second pipe",
|
|
|
|
name: "wikilink with numeric aliases#^blockRef|420|second pipe",
|
|
|
|
in: "[[wikilink#^blockRef|420|second pipe]]",
|
|
|
|
in: "[[wikilink#^blockRef|420|second pipe]]",
|
|
|
|
expected: []wikilink.Lexeme{
|
|
|
|
expected: []markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: markdown.LexOpenLink, Val: "[["},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "wikilink"},
|
|
|
|
{Typ: wikilink.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: markdown.LexBlockRef, Val: "#^"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "blockRef"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "420"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "420"},
|
|
|
|
{Typ: wikilink.LexAlias, Val: "|"},
|
|
|
|
{Typ: markdown.LexAlias, Val: "|"},
|
|
|
|
{Typ: wikilink.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: markdown.LexIdent, Val: "second pipe"},
|
|
|
|
{Typ: wikilink.LexCloseLink, Val: "]]"},
|
|
|
|
{Typ: markdown.LexCloseLink, Val: "]]"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -204,14 +204,14 @@ func Test_ObsidianWikilinks_LinksEndOfMultiLineInput(t *testing.T) {
|
|
|
|
" test data please ignore.\nbling blonk more lines\nbling blong\nthis is a",
|
|
|
|
" test data please ignore.\nbling blonk more lines\nbling blong\nthis is a",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
|
|
|
|
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: " test data please ignore.\n"},
|
|
|
|
{Typ: markdown.LexText, Val: " test data please ignore.\n"},
|
|
|
|
{Typ: wikilink.LexText, Val: "bling blonk more lines\n"},
|
|
|
|
{Typ: markdown.LexText, Val: "bling blonk more lines\n"},
|
|
|
|
{Typ: wikilink.LexText, Val: "bling blong\n"},
|
|
|
|
{Typ: markdown.LexText, Val: "bling blong\n"},
|
|
|
|
{Typ: wikilink.LexText, Val: "this is a"},
|
|
|
|
{Typ: markdown.LexText, Val: "this is a"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
{Typ: markdown.LexText, Val: ""},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
t.Run(mut.name, test)
|
|
|
@ -225,14 +225,14 @@ func Test_ObsidianWikilinks_LinksStartOfMultiLineInput(t *testing.T) {
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
" test data please ignore.\nbling blonk more lines\nbling blong\nthis is a",
|
|
|
|
" test data please ignore.\nbling blonk more lines\nbling blong\nthis is a",
|
|
|
|
|
|
|
|
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
{Typ: markdown.LexText, Val: ""},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: " test data please ignore.\n"},
|
|
|
|
{Typ: markdown.LexText, Val: " test data please ignore.\n"},
|
|
|
|
{Typ: wikilink.LexText, Val: "bling blonk more lines\n"},
|
|
|
|
{Typ: markdown.LexText, Val: "bling blonk more lines\n"},
|
|
|
|
{Typ: wikilink.LexText, Val: "bling blong\n"},
|
|
|
|
{Typ: markdown.LexText, Val: "bling blong\n"},
|
|
|
|
{Typ: wikilink.LexText, Val: "this is a"},
|
|
|
|
{Typ: markdown.LexText, Val: "this is a"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
t.Run(mut.name, test)
|
|
|
@ -246,11 +246,11 @@ func Test_ObsidianWikilinks_LinksStartOfInput(t *testing.T) {
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
" test data please ignore",
|
|
|
|
" test data please ignore",
|
|
|
|
|
|
|
|
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
{Typ: markdown.LexText, Val: ""},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: " test data please ignore"},
|
|
|
|
{Typ: markdown.LexText, Val: " test data please ignore"},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
t.Run(mut.name, test)
|
|
|
@ -263,11 +263,11 @@ func Test_ObsidianWikilinks_LinksEndOfInput(t *testing.T) {
|
|
|
|
tc,
|
|
|
|
tc,
|
|
|
|
"this is a ",
|
|
|
|
"this is a ",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: "this is a "},
|
|
|
|
{Typ: markdown.LexText, Val: "this is a "},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
{Typ: markdown.LexText, Val: ""},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
t.Run(mut.name, test)
|
|
|
@ -281,11 +281,11 @@ func Test_ObsidianWikilinks_Basic(t *testing.T) {
|
|
|
|
tc,
|
|
|
|
tc,
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
{Typ: markdown.LexText, Val: ""},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[]wikilink.Lexeme{
|
|
|
|
[]markdown.Lexeme{
|
|
|
|
{Typ: wikilink.LexText, Val: ""},
|
|
|
|
{Typ: markdown.LexText, Val: ""},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
t.Run(mut.name, test)
|
|
|
|
t.Run(mut.name, test)
|
|
|
@ -295,10 +295,10 @@ func Test_ObsidianWikilinks_Basic(t *testing.T) {
|
|
|
|
type tc struct {
|
|
|
|
type tc struct {
|
|
|
|
name string
|
|
|
|
name string
|
|
|
|
in string
|
|
|
|
in string
|
|
|
|
expected []wikilink.Lexeme
|
|
|
|
expected []markdown.Lexeme
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func mutateTestCase(tc tc, prefix, suffix string, expectedPrefix, expectedSuffix []wikilink.Lexeme) (tc, func(t *testing.T)) {
|
|
|
|
func mutateTestCase(tc tc, prefix, suffix string, expectedPrefix, expectedSuffix []markdown.Lexeme) (tc, func(t *testing.T)) {
|
|
|
|
tc.in = prefix + tc.in
|
|
|
|
tc.in = prefix + tc.in
|
|
|
|
tc.in = tc.in + suffix
|
|
|
|
tc.in = tc.in + suffix
|
|
|
|
if expectedPrefix != nil {
|
|
|
|
if expectedPrefix != nil {
|
|
|
@ -309,7 +309,7 @@ func mutateTestCase(tc tc, prefix, suffix string, expectedPrefix, expectedSuffix
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return tc, func(t *testing.T) {
|
|
|
|
return tc, func(t *testing.T) {
|
|
|
|
l := wikilink.Lex("testLexer", tc.in, zapcore.WarnLevel)
|
|
|
|
l := markdown.Lex("testLexer", tc.in, zapcore.WarnLevel)
|
|
|
|
defer l.L.Sync()
|
|
|
|
defer l.L.Sync()
|
|
|
|
assert.Equal(t, tc.expected, l.Items, "token stream mismatch")
|
|
|
|
assert.Equal(t, tc.expected, l.Items, "token stream mismatch")
|
|
|
|
}
|
|
|
|
}
|
|
|
|