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
54493420
Commit
54493420
authored
Jan 08, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: auto link converters
parent
43e42079
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
7 deletions
+19
-7
markdown_service.go
api/v2/markdown_service.go
+2
-2
auto_link.go
plugin/gomark/parser/auto_link.go
+2
-2
markdown_service.proto
proto/api/v2/markdown_service.proto
+1
-0
README.md
proto/gen/api/v2/README.md
+1
-0
markdown_service.pb.go
proto/gen/api/v2/markdown_service.pb.go
+13
-3
No files found.
api/v2/markdown_service.go
View file @
54493420
...
@@ -79,7 +79,7 @@ func convertFromASTNode(rawNode ast.Node) *apiv2pb.Node {
...
@@ -79,7 +79,7 @@ func convertFromASTNode(rawNode ast.Node) *apiv2pb.Node {
case
*
ast
.
Link
:
case
*
ast
.
Link
:
node
.
Node
=
&
apiv2pb
.
Node_LinkNode
{
LinkNode
:
&
apiv2pb
.
LinkNode
{
Text
:
n
.
Text
,
Url
:
n
.
URL
}}
node
.
Node
=
&
apiv2pb
.
Node_LinkNode
{
LinkNode
:
&
apiv2pb
.
LinkNode
{
Text
:
n
.
Text
,
Url
:
n
.
URL
}}
case
*
ast
.
AutoLink
:
case
*
ast
.
AutoLink
:
node
.
Node
=
&
apiv2pb
.
Node_AutoLinkNode
{
AutoLinkNode
:
&
apiv2pb
.
AutoLinkNode
{
Url
:
n
.
URL
}}
node
.
Node
=
&
apiv2pb
.
Node_AutoLinkNode
{
AutoLinkNode
:
&
apiv2pb
.
AutoLinkNode
{
Url
:
n
.
URL
,
IsRawText
:
n
.
IsRawText
}}
case
*
ast
.
Tag
:
case
*
ast
.
Tag
:
node
.
Node
=
&
apiv2pb
.
Node_TagNode
{
TagNode
:
&
apiv2pb
.
TagNode
{
Content
:
n
.
Content
}}
node
.
Node
=
&
apiv2pb
.
Node_TagNode
{
TagNode
:
&
apiv2pb
.
TagNode
{
Content
:
n
.
Content
}}
case
*
ast
.
Strikethrough
:
case
*
ast
.
Strikethrough
:
...
@@ -148,7 +148,7 @@ func convertToASTNode(node *apiv2pb.Node) ast.Node {
...
@@ -148,7 +148,7 @@ func convertToASTNode(node *apiv2pb.Node) ast.Node {
case
*
apiv2pb
.
Node_LinkNode
:
case
*
apiv2pb
.
Node_LinkNode
:
return
&
ast
.
Link
{
Text
:
n
.
LinkNode
.
Text
,
URL
:
n
.
LinkNode
.
Url
}
return
&
ast
.
Link
{
Text
:
n
.
LinkNode
.
Text
,
URL
:
n
.
LinkNode
.
Url
}
case
*
apiv2pb
.
Node_AutoLinkNode
:
case
*
apiv2pb
.
Node_AutoLinkNode
:
return
&
ast
.
AutoLink
{
URL
:
n
.
AutoLinkNode
.
Url
}
return
&
ast
.
AutoLink
{
URL
:
n
.
AutoLinkNode
.
Url
,
IsRawText
:
n
.
AutoLinkNode
.
IsRawText
}
case
*
apiv2pb
.
Node_TagNode
:
case
*
apiv2pb
.
Node_TagNode
:
return
&
ast
.
Tag
{
Content
:
n
.
TagNode
.
Content
}
return
&
ast
.
Tag
{
Content
:
n
.
TagNode
.
Content
}
case
*
apiv2pb
.
Node_StrikethroughNode
:
case
*
apiv2pb
.
Node_StrikethroughNode
:
...
...
plugin/gomark/parser/auto_link.go
View file @
54493420
...
@@ -58,9 +58,9 @@ func (p *AutoLinkParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
...
@@ -58,9 +58,9 @@ func (p *AutoLinkParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
url
:=
tokenizer
.
Stringify
(
tokens
[
:
size
])
url
:=
tokenizer
.
Stringify
(
tokens
[
:
size
])
isRawText
:=
true
isRawText
:=
true
if
tokens
[
0
]
.
Type
==
tokenizer
.
LessThan
&&
tokens
[
len
(
tokens
)
-
1
]
.
Type
==
tokenizer
.
GreaterThan
{
if
tokens
[
0
]
.
Type
==
tokenizer
.
LessThan
&&
tokens
[
size
-
1
]
.
Type
==
tokenizer
.
GreaterThan
{
isRawText
=
false
isRawText
=
false
url
=
tokenizer
.
Stringify
(
tokens
[
1
:
len
(
tokens
)
-
1
])
url
=
tokenizer
.
Stringify
(
tokens
[
1
:
size
-
1
])
}
}
return
&
ast
.
AutoLink
{
return
&
ast
.
AutoLink
{
URL
:
url
,
URL
:
url
,
...
...
proto/api/v2/markdown_service.proto
View file @
54493420
...
@@ -156,6 +156,7 @@ message LinkNode {
...
@@ -156,6 +156,7 @@ message LinkNode {
message
AutoLinkNode
{
message
AutoLinkNode
{
string
url
=
1
;
string
url
=
1
;
bool
is_raw_text
=
2
;
}
}
message
TagNode
{
message
TagNode
{
...
...
proto/gen/api/v2/README.md
View file @
54493420
...
@@ -968,6 +968,7 @@
...
@@ -968,6 +968,7 @@
| Field | Type | Label | Description |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| url |
[
string
](
#string
)
| | |
| url |
[
string
](
#string
)
| | |
| is_raw_text |
[
bool
](
#bool
)
| | |
...
...
proto/gen/api/v2/markdown_service.pb.go
View file @
54493420
...
@@ -1476,7 +1476,8 @@ type AutoLinkNode struct {
...
@@ -1476,7 +1476,8 @@ type AutoLinkNode struct {
sizeCache
protoimpl
.
SizeCache
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
unknownFields
protoimpl
.
UnknownFields
Url
string
`protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
Url
string
`protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
IsRawText
bool
`protobuf:"varint,2,opt,name=is_raw_text,json=isRawText,proto3" json:"is_raw_text,omitempty"`
}
}
func
(
x
*
AutoLinkNode
)
Reset
()
{
func
(
x
*
AutoLinkNode
)
Reset
()
{
...
@@ -1518,6 +1519,13 @@ func (x *AutoLinkNode) GetUrl() string {
...
@@ -1518,6 +1519,13 @@ func (x *AutoLinkNode) GetUrl() string {
return
""
return
""
}
}
func
(
x
*
AutoLinkNode
)
GetIsRawText
()
bool
{
if
x
!=
nil
{
return
x
.
IsRawText
}
return
false
}
type
TagNode
struct
{
type
TagNode
struct
{
state
protoimpl
.
MessageState
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
sizeCache
protoimpl
.
SizeCache
...
@@ -1887,9 +1895,11 @@ var file_api_v2_markdown_service_proto_rawDesc = []byte{
...
@@ -1887,9 +1895,11 @@ var file_api_v2_markdown_service_proto_rawDesc = []byte{
0x08
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x74
,
0x65
,
0x78
,
0x08
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x74
,
0x65
,
0x78
,
0x74
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x04
,
0x74
,
0x65
,
0x78
,
0x74
,
0x12
,
0x10
,
0x0a
,
0x74
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x04
,
0x74
,
0x65
,
0x78
,
0x74
,
0x12
,
0x10
,
0x0a
,
0x03
,
0x75
,
0x72
,
0x6c
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x03
,
0x75
,
0x72
,
0x6c
,
0x22
,
0x03
,
0x75
,
0x72
,
0x6c
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x03
,
0x75
,
0x72
,
0x6c
,
0x22
,
0x
2
0
,
0x0a
,
0x0c
,
0x41
,
0x75
,
0x74
,
0x6f
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x
4
0
,
0x0a
,
0x0c
,
0x41
,
0x75
,
0x74
,
0x6f
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x10
,
0x0a
,
0x03
,
0x75
,
0x72
,
0x6c
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x03
,
0x75
,
0x72
,
0x10
,
0x0a
,
0x03
,
0x75
,
0x72
,
0x6c
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x03
,
0x75
,
0x72
,
0x6c
,
0x22
,
0x23
,
0x0a
,
0x07
,
0x54
,
0x61
,
0x67
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x6c
,
0x12
,
0x1e
,
0x0a
,
0x0b
,
0x69
,
0x73
,
0x5f
,
0x72
,
0x61
,
0x77
,
0x5f
,
0x74
,
0x65
,
0x78
,
0x74
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x08
,
0x52
,
0x09
,
0x69
,
0x73
,
0x52
,
0x61
,
0x77
,
0x54
,
0x65
,
0x78
,
0x74
,
0x22
,
0x23
,
0x0a
,
0x07
,
0x54
,
0x61
,
0x67
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x07
,
0x63
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x07
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x22
,
0x2d
,
0x0a
,
0x11
,
0x53
,
0x74
,
0x72
,
0x69
,
0x6b
,
0x65
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x22
,
0x2d
,
0x0a
,
0x11
,
0x53
,
0x74
,
0x72
,
0x69
,
0x6b
,
0x65
,
0x74
,
0x68
,
0x72
,
0x6f
,
0x75
,
0x67
,
0x68
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x63
,
0x74
,
0x68
,
0x72
,
0x6f
,
0x75
,
0x67
,
0x68
,
0x4e
,
0x6f
,
0x64
,
0x65
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x63
,
...
...
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