Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
7eec4242
Commit
7eec4242
authored
Oct 26, 2025
by
Claude
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove references handling from markdown extraction
parent
6cb96ef6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
133 deletions
+9
-133
markdown.go
plugin/markdown/markdown.go
+4
-44
markdown_test.go
plugin/markdown/markdown_test.go
+0
-67
memo.pb.go
proto/gen/store/memo.pb.go
+5
-17
memo.proto
proto/store/memo.proto
+0
-2
runner.go
server/runner/memopayload/runner.go
+0
-3
No files found.
plugin/markdown/markdown.go
View file @
7eec4242
...
...
@@ -19,9 +19,8 @@ import (
// ExtractedData contains all metadata extracted from markdown in a single pass.
type
ExtractedData
struct
{
Tags
[]
string
Property
*
storepb
.
MemoPayload_Property
References
[]
string
Tags
[]
string
Property
*
storepb
.
MemoPayload_Property
}
// Service handles markdown metadata extraction.
...
...
@@ -38,9 +37,6 @@ type Service interface {
// ExtractProperties computes boolean properties
ExtractProperties
(
content
[]
byte
)
(
*
storepb
.
MemoPayload_Property
,
error
)
// ExtractReferences returns all wikilink references ([[...]]) found in content
ExtractReferences
(
content
[]
byte
)
([]
string
,
error
)
// RenderMarkdown renders goldmark AST back to markdown text
RenderMarkdown
(
content
[]
byte
)
(
string
,
error
)
...
...
@@ -195,36 +191,6 @@ func (s *service) ExtractProperties(content []byte) (*storepb.MemoPayload_Proper
return
prop
,
nil
}
// ExtractReferences returns all wikilink references found in content.
func
(
s
*
service
)
ExtractReferences
(
content
[]
byte
)
([]
string
,
error
)
{
root
,
err
:=
s
.
parse
(
content
)
if
err
!=
nil
{
return
nil
,
err
}
references
:=
[]
string
{}
// Initialize to empty slice, not nil
// Walk the AST to find wikilink nodes
err
=
gast
.
Walk
(
root
,
func
(
n
gast
.
Node
,
entering
bool
)
(
gast
.
WalkStatus
,
error
)
{
if
!
entering
{
return
gast
.
WalkContinue
,
nil
}
// Check for custom WikilinkNode
if
wikilinkNode
,
ok
:=
n
.
(
*
mast
.
WikilinkNode
);
ok
{
references
=
append
(
references
,
string
(
wikilinkNode
.
Target
))
}
return
gast
.
WalkContinue
,
nil
})
if
err
!=
nil
{
return
nil
,
err
}
return
references
,
nil
}
// RenderMarkdown renders goldmark AST back to markdown text.
func
(
s
*
service
)
RenderMarkdown
(
content
[]
byte
)
(
string
,
error
)
{
root
,
err
:=
s
.
parse
(
content
)
...
...
@@ -338,9 +304,8 @@ func (s *service) ExtractAll(content []byte) (*ExtractedData, error) {
}
data
:=
&
ExtractedData
{
Tags
:
[]
string
{},
Property
:
&
storepb
.
MemoPayload_Property
{},
References
:
[]
string
{},
Tags
:
[]
string
{},
Property
:
&
storepb
.
MemoPayload_Property
{},
}
// Single walk to collect all data
...
...
@@ -354,11 +319,6 @@ func (s *service) ExtractAll(content []byte) (*ExtractedData, error) {
data
.
Tags
=
append
(
data
.
Tags
,
string
(
tagNode
.
Tag
))
}
// Extract references (wikilinks)
if
wikilinkNode
,
ok
:=
n
.
(
*
mast
.
WikilinkNode
);
ok
{
data
.
References
=
append
(
data
.
References
,
string
(
wikilinkNode
.
Target
))
}
// Extract properties based on node kind
switch
n
.
Kind
()
{
case
gast
.
KindLink
,
mast
.
KindWikilink
:
...
...
plugin/markdown/markdown_test.go
View file @
7eec4242
...
...
@@ -302,73 +302,6 @@ func TestExtractTags(t *testing.T) {
}
}
func
TestExtractReferences
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
content
string
withExt
bool
expected
[]
string
}{
{
name
:
"no references"
,
content
:
"Just plain text"
,
withExt
:
false
,
expected
:
[]
string
{},
},
{
name
:
"single wikilink"
,
content
:
"Check this: [[resources/101]]"
,
withExt
:
true
,
expected
:
[]
string
{
"resources/101"
},
},
{
name
:
"multiple wikilinks"
,
content
:
"[[resources/101]]
\n\n
And also: [[memos/42]]"
,
withExt
:
true
,
expected
:
[]
string
{
"resources/101"
,
"memos/42"
},
},
{
name
:
"wikilink with params"
,
content
:
"[[resources/101?align=center]]"
,
withExt
:
true
,
expected
:
[]
string
{
"resources/101"
},
},
{
name
:
"duplicate wikilinks"
,
content
:
"[[resources/101]]
\n\n
[[resources/101]]"
,
withExt
:
true
,
expected
:
[]
string
{
"resources/101"
,
"resources/101"
},
// Not deduplicated at this layer
},
{
name
:
"no extension enabled"
,
content
:
"[[resources/101]]"
,
withExt
:
false
,
expected
:
[]
string
{},
},
{
name
:
"wikilink in sentence"
,
content
:
"Check [[memos/1]] for details"
,
withExt
:
true
,
expected
:
[]
string
{
"memos/1"
},
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
var
svc
Service
if
tt
.
withExt
{
svc
=
NewService
(
WithWikilinkExtension
())
}
else
{
svc
=
NewService
()
}
references
,
err
:=
svc
.
ExtractReferences
([]
byte
(
tt
.
content
))
require
.
NoError
(
t
,
err
)
assert
.
Equal
(
t
,
tt
.
expected
,
references
)
})
}
}
func
TestUniqueLowercase
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
...
...
proto/gen/store/memo.pb.go
View file @
7eec4242
...
...
@@ -88,10 +88,8 @@ type MemoPayload_Property struct {
HasTaskList
bool
`protobuf:"varint,2,opt,name=has_task_list,json=hasTaskList,proto3" json:"has_task_list,omitempty"`
HasCode
bool
`protobuf:"varint,3,opt,name=has_code,json=hasCode,proto3" json:"has_code,omitempty"`
HasIncompleteTasks
bool
`protobuf:"varint,4,opt,name=has_incomplete_tasks,json=hasIncompleteTasks,proto3" json:"has_incomplete_tasks,omitempty"`
// The references of the memo. Should be a list of uuid.
References
[]
string
`protobuf:"bytes,5,rep,name=references,proto3" json:"references,omitempty"`
unknownFields
protoimpl
.
UnknownFields
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
sizeCache
protoimpl
.
SizeCache
}
func
(
x
*
MemoPayload_Property
)
Reset
()
{
...
...
@@ -152,13 +150,6 @@ func (x *MemoPayload_Property) GetHasIncompleteTasks() bool {
return
false
}
func
(
x
*
MemoPayload_Property
)
GetReferences
()
[]
string
{
if
x
!=
nil
{
return
x
.
References
}
return
nil
}
type
MemoPayload_Location
struct
{
state
protoimpl
.
MessageState
`protogen:"open.v1"`
Placeholder
string
`protobuf:"bytes,1,opt,name=placeholder,proto3" json:"placeholder,omitempty"`
...
...
@@ -223,19 +214,16 @@ var File_store_memo_proto protoreflect.FileDescriptor
const
file_store_memo_proto_rawDesc
=
""
+
"
\n
"
+
"
\x10
store/memo.proto
\x12\v
memos.store
\"\x
c
0\x03\n
"
+
"
\x10
store/memo.proto
\x12\v
memos.store
\"\x
a
0\x03\n
"
+
"
\v
MemoPayload
\x12
=
\n
"
+
"
\b
property
\x18\x01
\x01
(
\v
2!.memos.store.MemoPayload.PropertyR
\b
property
\x12
=
\n
"
+
"
\b
location
\x18\x02
\x01
(
\v
2!.memos.store.MemoPayload.LocationR
\b
location
\x12\x12\n
"
+
"
\x04
tags
\x18\x03
\x03
(
\t
R
\x04
tags
\x1a\x
b
6\x01\n
"
+
"
\x04
tags
\x18\x03
\x03
(
\t
R
\x04
tags
\x1a\x
9
6\x01\n
"
+
"
\b
Property
\x12\x19\n
"
+
"
\b
has_link
\x18\x01
\x01
(
\b
R
\a
hasLink
\x12\"\n
"
+
"
\r
has_task_list
\x18\x02
\x01
(
\b
R
\v
hasTaskList
\x12\x19\n
"
+
"
\b
has_code
\x18\x03
\x01
(
\b
R
\a
hasCode
\x12
0
\n
"
+
"
\x14
has_incomplete_tasks
\x18\x04
\x01
(
\b
R
\x12
hasIncompleteTasks
\x12\x1e\n
"
+
"
\n
"
+
"references
\x18\x05
\x03
(
\t
R
\n
"
+
"references
\x1a
f
\n
"
+
"
\x14
has_incomplete_tasks
\x18\x04
\x01
(
\b
R
\x12
hasIncompleteTasks
\x1a
f
\n
"
+
"
\b
Location
\x12
\n
"
+
"
\v
placeholder
\x18\x01
\x01
(
\t
R
\v
placeholder
\x12\x1a\n
"
+
"
\b
latitude
\x18\x02
\x01
(
\x01
R
\b
latitude
\x12\x1c\n
"
+
...
...
proto/store/memo.proto
View file @
7eec4242
...
...
@@ -17,8 +17,6 @@ message MemoPayload {
bool
has_task_list
=
2
;
bool
has_code
=
3
;
bool
has_incomplete_tasks
=
4
;
// The references of the memo. Should be a list of uuid.
repeated
string
references
=
5
;
}
message
Location
{
...
...
server/runner/memopayload/runner.go
View file @
7eec4242
...
...
@@ -82,9 +82,6 @@ func RebuildMemoPayload(memo *store.Memo, markdownService markdown.Service) erro
return
errors
.
Wrap
(
err
,
"failed to extract markdown metadata"
)
}
// Set references in property
data
.
Property
.
References
=
data
.
References
memo
.
Payload
.
Tags
=
data
.
Tags
memo
.
Payload
.
Property
=
data
.
Property
return
nil
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment