From a10a5cb3c5f8d6a834e00fa58de6b9f885de388c Mon Sep 17 00:00:00 2001 From: alexander Date: Thu, 18 Apr 2024 21:46:36 -0700 Subject: [PATCH] exported inlineParser --- examples/inline.go | 2 +- parser/parser.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/inline.go b/examples/inline.go index 4c570bd..663bd61 100644 --- a/examples/inline.go +++ b/examples/inline.go @@ -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) diff --git a/parser/parser.go b/parser/parser.go index f0a0d9c..8d72b64 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -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 @@ -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 @@ -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