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
d7ed5958
Commit
d7ed5958
authored
Jan 04, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix math block matcher
parent
9593b0b0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
2 deletions
+24
-2
ast.go
plugin/gomark/ast/ast.go
+1
-1
math_block.go
plugin/gomark/parser/math_block.go
+1
-1
math_block_test.go
plugin/gomark/parser/math_block_test.go
+6
-0
parser_test.go
plugin/gomark/parser/parser_test.go
+16
-0
No files found.
plugin/gomark/ast/ast.go
View file @
d7ed5958
...
...
@@ -74,7 +74,7 @@ func (n *BaseNode) SetNextSibling(node Node) {
func
IsBlockNode
(
node
Node
)
bool
{
switch
node
.
Type
()
{
case
ParagraphNode
,
CodeBlockNode
,
HeadingNode
,
HorizontalRuleNode
,
BlockquoteNode
,
OrderedListNode
,
UnorderedListNode
,
TaskListNode
:
case
ParagraphNode
,
CodeBlockNode
,
HeadingNode
,
HorizontalRuleNode
,
BlockquoteNode
,
OrderedListNode
,
UnorderedListNode
,
TaskListNode
,
MathBlockNode
:
return
true
default
:
return
false
...
...
plugin/gomark/parser/math_block.go
View file @
d7ed5958
...
...
@@ -18,7 +18,7 @@ func (*MathBlockParser) Match(tokens []*tokenizer.Token) (int, bool) {
return
0
,
false
}
if
tokens
[
0
]
.
Type
!=
tokenizer
.
DollarSign
&&
tokens
[
1
]
.
Type
!=
tokenizer
.
DollarSign
&&
tokens
[
2
]
.
Type
!=
tokenizer
.
Newline
{
if
tokens
[
0
]
.
Type
!=
tokenizer
.
DollarSign
||
tokens
[
1
]
.
Type
!=
tokenizer
.
DollarSign
||
tokens
[
2
]
.
Type
!=
tokenizer
.
Newline
{
return
0
,
false
}
...
...
plugin/gomark/parser/math_block_test.go
View file @
d7ed5958
...
...
@@ -21,6 +21,12 @@ func TestMathBlockParser(t *testing.T) {
Content
:
"(1+x)^2"
,
},
},
{
text
:
"$$
\n
a=3
\n
$$"
,
link
:
&
ast
.
MathBlock
{
Content
:
"a=3"
,
},
},
}
for
_
,
test
:=
range
tests
{
tokens
:=
tokenizer
.
Tokenize
(
test
.
text
)
...
...
plugin/gomark/parser/parser_test.go
View file @
d7ed5958
...
...
@@ -197,6 +197,22 @@ func TestParser(t *testing.T) {
},
},
},
{
text
:
"
\n\n
"
,
nodes
:
[]
ast
.
Node
{
&
ast
.
LineBreak
{},
&
ast
.
LineBreak
{},
},
},
{
text
:
"
\n
$$
\n
a=3
\n
$$"
,
nodes
:
[]
ast
.
Node
{
&
ast
.
LineBreak
{},
&
ast
.
MathBlock
{
Content
:
"a=3"
,
},
},
},
}
for
_
,
test
:=
range
tests
{
...
...
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