Skip to content

Commit

Permalink
exported inlineParser
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander committed Apr 19, 2024
1 parent 4d01890 commit a10a5cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var mds = `This is a [[wiki link]].
// wikiLink returns an inline parser function. This indirection is
// required because we want to call the previous definition in case
// this is not a wikiLink.
func wikiLink(p *parser.Parser, fn func(p *parser.Parser, data []byte, offset int) (int, ast.Node)) func(p *parser.Parser, data []byte, offset int) (int, ast.Node) {
func wikiLink(p *parser.Parser, fn parser.InlineParser) parser.InlineParser {
return func (p *parser.Parser, original []byte, offset int) (int, ast.Node) {
data := original[offset:]
n := len(data)
Expand Down
6 changes: 3 additions & 3 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (
)

// for each character that triggers a response when parsing inline data.
type inlineParser func(p *Parser, data []byte, offset int) (int, ast.Node)
type InlineParser func(p *Parser, data []byte, offset int) (int, ast.Node)

// ReferenceOverrideFunc is expected to be called with a reference string and
// return either a valid Reference type that the reference string maps to or
Expand Down Expand Up @@ -98,7 +98,7 @@ type Parser struct {

refs map[string]*reference
refsRecord map[string]struct{}
inlineCallback [256]inlineParser
inlineCallback [256]InlineParser
nesting int
maxNesting int
insideLink bool
Expand Down Expand Up @@ -181,7 +181,7 @@ func NewWithExtensions(extension Extensions) *Parser {
return &p
}

func (p *Parser) RegisterInline(n byte, fn inlineParser) inlineParser {
func (p *Parser) RegisterInline(n byte, fn InlineParser) InlineParser {
prev := p.inlineCallback[n]
p.inlineCallback[n] = fn
return prev
Expand Down

0 comments on commit a10a5cb

Please sign in to comment.