Skip to content

Commit

Permalink
✏️ Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Aug 7, 2019
1 parent d291048 commit 6f68842
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 87 deletions.
20 changes: 10 additions & 10 deletions ast/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,27 +166,27 @@ func NewHeading(level int) *Heading {
}
}

// A ThemanticBreak struct represents a thematic break of Markdown text.
type ThemanticBreak struct {
// A ThematicBreak struct represents a thematic break of Markdown text.
type ThematicBreak struct {
BaseBlock
}

// Dump implements Node.Dump .
func (n *ThemanticBreak) Dump(source []byte, level int) {
func (n *ThematicBreak) Dump(source []byte, level int) {
DumpHelper(n, source, level, nil, nil)
}

// KindThemanticBreak is a NodeKind of the ThemanticBreak node.
var KindThemanticBreak = NewNodeKind("ThemanticBreak")
// KindThematicBreak is a NodeKind of the ThematicBreak node.
var KindThematicBreak = NewNodeKind("ThematicBreak")

// Kind implements Node.Kind.
func (n *ThemanticBreak) Kind() NodeKind {
return KindThemanticBreak
func (n *ThematicBreak) Kind() NodeKind {
return KindThematicBreak
}

// NewThemanticBreak returns a new ThemanticBreak node.
func NewThemanticBreak() *ThemanticBreak {
return &ThemanticBreak{
// NewThematicBreak returns a new ThematicBreak node.
func NewThematicBreak() *ThematicBreak {
return &ThematicBreak{
BaseBlock: BaseBlock{},
}
}
Expand Down
4 changes: 2 additions & 2 deletions parser/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ func (b *listParser) Continue(node ast.Node, reader text.Reader, pc Context) Sta
}
return Continue | HasChildren
}
// Themantic Breaks take precedence over lists
if isThemanticBreak(line) {
// Thematic Breaks take precedence over lists
if isThematicBreak(line) {
isHeading := false
last := pc.LastOpenedBlock().Node
if ast.IsParagraph(last) {
Expand Down
4 changes: 2 additions & 2 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ type ASTTransformer interface {
// Priorities of default BlockParsers are:
//
// SetextHeadingParser, 100
// ThemanticBreakParser, 200
// ThematicBreakParser, 200
// ListParser, 300
// ListItemParser, 400
// CodeBlockParser, 500
Expand All @@ -532,7 +532,7 @@ type ASTTransformer interface {
func DefaultBlockParsers() []util.PrioritizedValue {
return []util.PrioritizedValue{
util.Prioritized(NewSetextHeadingParser(), 100),
util.Prioritized(NewThemanticBreakParser(), 200),
util.Prioritized(NewThematicBreakParser(), 200),
util.Prioritized(NewListParser(), 300),
util.Prioritized(NewListItemParser(), 400),
util.Prioritized(NewCodeBlockParser(), 500),
Expand Down
71 changes: 0 additions & 71 deletions parser/themantic_break.go

This file was deleted.

71 changes: 71 additions & 0 deletions parser/thematic_break.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package parser

import (
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/text"
"github.com/yuin/goldmark/util"
)

type ThematicBreakParser struct {
}

var defaultThematicBreakParser = &ThematicBreakParser{}

// NewThematicBreakParser returns a new BlockParser that
// parses thematic breaks.
func NewThematicBreakParser() BlockParser {
return defaultThematicBreakParser
}

func isThematicBreak(line []byte) bool {
w, pos := util.IndentWidth(line, 0)
if w > 3 {
return false
}
mark := byte(0)
count := 0
for i := pos; i < len(line); i++ {
c := line[i]
if util.IsSpace(c) {
continue
}
if mark == 0 {
mark = c
count = 1
if mark == '*' || mark == '-' || mark == '_' {
continue
}
return false
}
if c != mark {
return false
}
count++
}
return count > 2
}

func (b *ThematicBreakParser) Open(parent ast.Node, reader text.Reader, pc Context) (ast.Node, State) {
line, segment := reader.PeekLine()
if isThematicBreak(line) {
reader.Advance(segment.Len() - 1)
return ast.NewThematicBreak(), NoChildren
}
return nil, NoChildren
}

func (b *ThematicBreakParser) Continue(node ast.Node, reader text.Reader, pc Context) State {
return Close
}

func (b *ThematicBreakParser) Close(node ast.Node, reader text.Reader, pc Context) {
// nothing to do
}

func (b *ThematicBreakParser) CanInterruptParagraph() bool {
return true
}

func (b *ThematicBreakParser) CanAcceptIndentedLine() bool {
return false
}
4 changes: 2 additions & 2 deletions renderer/html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (r *Renderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
reg.Register(ast.KindListItem, r.renderListItem)
reg.Register(ast.KindParagraph, r.renderParagraph)
reg.Register(ast.KindTextBlock, r.renderTextBlock)
reg.Register(ast.KindThemanticBreak, r.renderThemanticBreak)
reg.Register(ast.KindThematicBreak, r.renderThematicBreak)

// inlines

Expand Down Expand Up @@ -333,7 +333,7 @@ func (r *Renderer) renderTextBlock(w util.BufWriter, source []byte, n ast.Node,
return ast.WalkContinue, nil
}

func (r *Renderer) renderThemanticBreak(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) {
func (r *Renderer) renderThematicBreak(w util.BufWriter, source []byte, n ast.Node, entering bool) (ast.WalkStatus, error) {
if !entering {
return ast.WalkContinue, nil
}
Expand Down

0 comments on commit 6f68842

Please sign in to comment.