From ba68130862dc004a7a1b50d99fc70872d39fd065 Mon Sep 17 00:00:00 2001 From: JP Appel Date: Wed, 2 Jul 2025 00:06:10 -0400 Subject: Add link parsing --- pkg/index/index_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'pkg/index/index_test.go') diff --git a/pkg/index/index_test.go b/pkg/index/index_test.go index 0a3239d..69600c2 100644 --- a/pkg/index/index_test.go +++ b/pkg/index/index_test.go @@ -250,6 +250,31 @@ func TestIndex_ParseOne(t *testing.T) { &index.Document{OtherMeta: "unknownKey: value\n"}, nil, }, + { + "links", + func(t *testing.T) string { + f, path := newTestFile(t, "links") + defer f.Close() + + f.WriteString("---\n") + f.WriteString("title: Link test\n") + f.WriteString("---\n") + f.WriteString(` + Here are some words in a *markdown* file. + In this sentence there is a valid [hyperlink](https://jpappel.xyz). + But in this sentence, the [link]() should not get parsed. + The same is true for the [link]( ) in this sentence. + `) + + return path + }, + index.ParseOpts{ParseLinks: true}, + &index.Document{ + Title: "Link test", + Links: []string{"https://jpappel.xyz"}, + }, + nil, + }, { "bad tags", func(t *testing.T) string { -- cgit v1.2.3