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
3edce174
Commit
3edce174
authored
Dec 13, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove unused methods
parent
5266a626
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
50 deletions
+15
-50
node.go
plugin/gomark/ast/node.go
+0
-32
blockquote.go
plugin/gomark/parser/blockquote.go
+4
-4
heading.go
plugin/gomark/parser/heading.go
+5
-6
paragraph.go
plugin/gomark/parser/paragraph.go
+4
-4
parser.go
plugin/gomark/parser/parser.go
+2
-4
No files found.
plugin/gomark/ast/node.go
View file @
3edce174
...
@@ -8,29 +8,17 @@ type Node interface {
...
@@ -8,29 +8,17 @@ type Node interface {
// This method is used for debugging.
// This method is used for debugging.
String
()
string
String
()
string
// GetParent returns a parent node of this node.
GetParent
()
Node
// GetPrevSibling returns a previous sibling node of this node.
// GetPrevSibling returns a previous sibling node of this node.
GetPrevSibling
()
Node
GetPrevSibling
()
Node
// GetNextSibling returns a next sibling node of this node.
// GetNextSibling returns a next sibling node of this node.
GetNextSibling
()
Node
GetNextSibling
()
Node
// GetChildren returns children nodes of this node.
GetChildren
()
[]
Node
// SetParent sets a parent node to this node.
SetParent
(
Node
)
// SetPrevSibling sets a previous sibling node to this node.
// SetPrevSibling sets a previous sibling node to this node.
SetPrevSibling
(
Node
)
SetPrevSibling
(
Node
)
// SetNextSibling sets a next sibling node to this node.
// SetNextSibling sets a next sibling node to this node.
SetNextSibling
(
Node
)
SetNextSibling
(
Node
)
// SetChildren sets children nodes to this node.
SetChildren
([]
Node
)
}
}
type
NodeType
int
type
NodeType
int
...
@@ -49,17 +37,9 @@ func NewNodeType(name string) NodeType {
...
@@ -49,17 +37,9 @@ func NewNodeType(name string) NodeType {
}
}
type
BaseNode
struct
{
type
BaseNode
struct
{
parent
Node
prevSibling
Node
prevSibling
Node
nextSibling
Node
nextSibling
Node
children
[]
Node
}
func
(
n
*
BaseNode
)
GetParent
()
Node
{
return
n
.
parent
}
}
func
(
n
*
BaseNode
)
GetPrevSibling
()
Node
{
func
(
n
*
BaseNode
)
GetPrevSibling
()
Node
{
...
@@ -70,14 +50,6 @@ func (n *BaseNode) GetNextSibling() Node {
...
@@ -70,14 +50,6 @@ func (n *BaseNode) GetNextSibling() Node {
return
n
.
nextSibling
return
n
.
nextSibling
}
}
func
(
n
*
BaseNode
)
GetChildren
()
[]
Node
{
return
n
.
children
}
func
(
n
*
BaseNode
)
SetParent
(
node
Node
)
{
n
.
parent
=
node
}
func
(
n
*
BaseNode
)
SetPrevSibling
(
node
Node
)
{
func
(
n
*
BaseNode
)
SetPrevSibling
(
node
Node
)
{
n
.
prevSibling
=
node
n
.
prevSibling
=
node
}
}
...
@@ -85,7 +57,3 @@ func (n *BaseNode) SetPrevSibling(node Node) {
...
@@ -85,7 +57,3 @@ func (n *BaseNode) SetPrevSibling(node Node) {
func
(
n
*
BaseNode
)
SetNextSibling
(
node
Node
)
{
func
(
n
*
BaseNode
)
SetNextSibling
(
node
Node
)
{
n
.
nextSibling
=
node
n
.
nextSibling
=
node
}
}
func
(
n
*
BaseNode
)
SetChildren
(
nodes
[]
Node
)
{
n
.
children
=
nodes
}
plugin/gomark/parser/blockquote.go
View file @
3edce174
...
@@ -42,11 +42,11 @@ func (p *BlockquoteParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
...
@@ -42,11 +42,11 @@ func (p *BlockquoteParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
}
}
contentTokens
:=
tokens
[
2
:
size
]
contentTokens
:=
tokens
[
2
:
size
]
blockquote
:=
&
ast
.
Blockquote
{}
children
,
err
:=
ParseInline
(
contentTokens
)
children
,
err
:=
ParseInline
(
blockquote
,
contentTokens
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
blockquote
.
Children
=
children
return
&
ast
.
Blockquote
{
return
blockquote
,
nil
Children
:
children
,
},
nil
}
}
plugin/gomark/parser/heading.go
View file @
3edce174
...
@@ -65,13 +65,12 @@ func (p *HeadingParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
...
@@ -65,13 +65,12 @@ func (p *HeadingParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
}
}
contentTokens
:=
tokens
[
level
+
1
:
size
]
contentTokens
:=
tokens
[
level
+
1
:
size
]
heading
:=
&
ast
.
Heading
{
children
,
err
:=
ParseInline
(
contentTokens
)
Level
:
level
,
}
children
,
err
:=
ParseInline
(
heading
,
contentTokens
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
heading
.
Children
=
children
return
&
ast
.
Heading
{
return
heading
,
nil
Level
:
level
,
Children
:
children
,
},
nil
}
}
plugin/gomark/parser/paragraph.go
View file @
3edce174
...
@@ -39,11 +39,11 @@ func (p *ParagraphParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
...
@@ -39,11 +39,11 @@ func (p *ParagraphParser) Parse(tokens []*tokenizer.Token) (ast.Node, error) {
}
}
contentTokens
:=
tokens
[
:
size
]
contentTokens
:=
tokens
[
:
size
]
paragraph
:=
&
ast
.
Paragraph
{}
children
,
err
:=
ParseInline
(
contentTokens
)
children
,
err
:=
ParseInline
(
paragraph
,
contentTokens
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
paragraph
.
Children
=
children
return
&
ast
.
Paragraph
{
return
paragraph
,
nil
Children
:
children
,
},
nil
}
}
plugin/gomark/parser/parser.go
View file @
3edce174
...
@@ -73,7 +73,7 @@ var defaultInlineParsers = []InlineParser{
...
@@ -73,7 +73,7 @@ var defaultInlineParsers = []InlineParser{
NewTextParser
(),
NewTextParser
(),
}
}
func
ParseInline
(
parent
ast
.
Node
,
tokens
[]
*
tokenizer
.
Token
)
([]
ast
.
Node
,
error
)
{
func
ParseInline
(
tokens
[]
*
tokenizer
.
Token
)
([]
ast
.
Node
,
error
)
{
nodes
:=
[]
ast
.
Node
{}
nodes
:=
[]
ast
.
Node
{}
var
prevNode
ast
.
Node
var
prevNode
ast
.
Node
for
len
(
tokens
)
>
0
{
for
len
(
tokens
)
>
0
{
...
@@ -86,8 +86,8 @@ func ParseInline(parent ast.Node, tokens []*tokenizer.Token) ([]ast.Node, error)
...
@@ -86,8 +86,8 @@ func ParseInline(parent ast.Node, tokens []*tokenizer.Token) ([]ast.Node, error)
}
}
tokens
=
tokens
[
size
:
]
tokens
=
tokens
[
size
:
]
node
.
SetParent
(
parent
)
if
prevNode
!=
nil
{
if
prevNode
!=
nil
{
// Merge text nodes if possible.
if
prevNode
.
Type
()
==
ast
.
NodeTypeText
&&
node
.
Type
()
==
ast
.
NodeTypeText
{
if
prevNode
.
Type
()
==
ast
.
NodeTypeText
&&
node
.
Type
()
==
ast
.
NodeTypeText
{
prevNode
.
(
*
ast
.
Text
)
.
Content
+=
node
.
(
*
ast
.
Text
)
.
Content
prevNode
.
(
*
ast
.
Text
)
.
Content
+=
node
.
(
*
ast
.
Text
)
.
Content
break
break
...
@@ -96,13 +96,11 @@ func ParseInline(parent ast.Node, tokens []*tokenizer.Token) ([]ast.Node, error)
...
@@ -96,13 +96,11 @@ func ParseInline(parent ast.Node, tokens []*tokenizer.Token) ([]ast.Node, error)
prevNode
.
SetNextSibling
(
node
)
prevNode
.
SetNextSibling
(
node
)
node
.
SetPrevSibling
(
prevNode
)
node
.
SetPrevSibling
(
prevNode
)
}
}
nodes
=
append
(
nodes
,
node
)
nodes
=
append
(
nodes
,
node
)
prevNode
=
node
prevNode
=
node
break
break
}
}
}
}
}
}
parent
.
SetChildren
(
nodes
)
return
nodes
,
nil
return
nodes
,
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