Skip to content

Commit

Permalink
🎨 一点微弱的优化
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Feb 2, 2020
1 parent 03e2719 commit e006d36
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions delimiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func (t *Tree) handleDelim(block *Node, ctx *InlineContext) {

// processEmphasis 处理强调、加粗以及删除线。
func (t *Tree) processEmphasis(stackBottom *delimiter, ctx *InlineContext) {
if nil == ctx.delimiters {
return
}

var opener, closer, oldCloser *delimiter
var openerInl, closerInl *Node
var tempStack *delimiter
Expand Down
6 changes: 2 additions & 4 deletions inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,15 @@ func (t *Tree) parseBackslash(block *Node, ctx *InlineContext) *Node {
return &Node{typ: NodeText, tokens: backslash}
}

func (t *Tree) parseText(ctx *InlineContext) (ret *Node) {
func (t *Tree) parseText(ctx *InlineContext) *Node {
start := ctx.pos
for ; ctx.pos < ctx.tokensLen; ctx.pos++ {
if t.isMarker(ctx.tokens[ctx.pos]) {
// 遇到潜在的标记符时需要跳出该文本节点,回到行级解析主循环
break
}
}

ret = &Node{typ: NodeText, tokens: ctx.tokens[start:ctx.pos]}
return
return &Node{typ: NodeText, tokens: ctx.tokens[start:ctx.pos]}
}

// isMarker 判断 token 是否是潜在的 Markdown 标记符。
Expand Down

0 comments on commit e006d36

Please sign in to comment.