mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fix #64 and some lint warnings
This commit is contained in:
parent
5b25bb53dd
commit
6d2e5fddae
6 changed files with 15 additions and 8 deletions
|
|
@ -130,3 +130,10 @@ https://github.com/sunday's
|
||||||
//- - - - - - - - -//
|
//- - - - - - - - -//
|
||||||
<p><a href="https://github.com/sunday's">https://github.com/sunday's</a></p>
|
<p><a href="https://github.com/sunday's">https://github.com/sunday's</a></p>
|
||||||
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
||||||
|
13
|
||||||
|
//- - - - - - - - -//
|
||||||
|
https://github.com?q=stars:>1
|
||||||
|
//- - - - - - - - -//
|
||||||
|
<p><a href="https://github.com?q=stars:%3E1">https://github.com?q=stars:>1</a></p>
|
||||||
|
//= = = = = = = = = = = = = = = = = = = = = = = =//
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import (
|
||||||
|
|
||||||
var wwwURLRegxp = regexp.MustCompile(`^www\.[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&//=\(\);,'"]*)`)
|
var wwwURLRegxp = regexp.MustCompile(`^www\.[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&//=\(\);,'"]*)`)
|
||||||
|
|
||||||
var urlRegexp = regexp.MustCompile(`^(?:http|https|ftp):\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=\(\);,'"]*)`)
|
var urlRegexp = regexp.MustCompile(`^(?:http|https|ftp):\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+\.~#$!?&//=\(\);,'"<>\^{}\[\]` + "`" + `]*)`)
|
||||||
|
|
||||||
type linkifyParser struct {
|
type linkifyParser struct {
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -127,15 +127,15 @@ func ScanDelimiter(line []byte, before rune, min int, processor DelimiterProcess
|
||||||
after = util.ToRune(line, j)
|
after = util.ToRune(line, j)
|
||||||
}
|
}
|
||||||
|
|
||||||
isLeft, isRight, canOpen, canClose := false, false, false, false
|
canOpen, canClose := false, false
|
||||||
beforeIsPunctuation := unicode.IsPunct(before)
|
beforeIsPunctuation := unicode.IsPunct(before)
|
||||||
beforeIsWhitespace := unicode.IsSpace(before)
|
beforeIsWhitespace := unicode.IsSpace(before)
|
||||||
afterIsPunctuation := unicode.IsPunct(after)
|
afterIsPunctuation := unicode.IsPunct(after)
|
||||||
afterIsWhitespace := unicode.IsSpace(after)
|
afterIsWhitespace := unicode.IsSpace(after)
|
||||||
|
|
||||||
isLeft = !afterIsWhitespace &&
|
isLeft := !afterIsWhitespace &&
|
||||||
(!afterIsPunctuation || beforeIsWhitespace || beforeIsPunctuation)
|
(!afterIsPunctuation || beforeIsWhitespace || beforeIsPunctuation)
|
||||||
isRight = !beforeIsWhitespace &&
|
isRight := !beforeIsWhitespace &&
|
||||||
(!beforeIsPunctuation || afterIsWhitespace || afterIsPunctuation)
|
(!beforeIsPunctuation || afterIsWhitespace || afterIsPunctuation)
|
||||||
|
|
||||||
if line[i] == '_' {
|
if line[i] == '_' {
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,7 @@ func (b *htmlBlockParser) Open(parent ast.Node, reader text.Reader, pc Context)
|
||||||
return nil, NoChildren
|
return nil, NoChildren
|
||||||
}
|
}
|
||||||
|
|
||||||
tagName := ""
|
|
||||||
if m := htmlBlockType1OpenRegexp.FindSubmatchIndex(line); m != nil {
|
if m := htmlBlockType1OpenRegexp.FindSubmatchIndex(line); m != nil {
|
||||||
tagName = string(line[m[2]:m[3]])
|
|
||||||
node = ast.NewHTMLBlock(ast.HTMLBlockType1)
|
node = ast.NewHTMLBlock(ast.HTMLBlockType1)
|
||||||
} else if htmlBlockType2OpenRegexp.Match(line) {
|
} else if htmlBlockType2OpenRegexp.Match(line) {
|
||||||
node = ast.NewHTMLBlock(ast.HTMLBlockType2)
|
node = ast.NewHTMLBlock(ast.HTMLBlockType2)
|
||||||
|
|
@ -133,7 +131,7 @@ func (b *htmlBlockParser) Open(parent ast.Node, reader text.Reader, pc Context)
|
||||||
} else if match := htmlBlockType7Regexp.FindSubmatchIndex(line); match != nil {
|
} else if match := htmlBlockType7Regexp.FindSubmatchIndex(line); match != nil {
|
||||||
isCloseTag := match[2] > -1 && bytes.Equal(line[match[2]:match[3]], []byte("/"))
|
isCloseTag := match[2] > -1 && bytes.Equal(line[match[2]:match[3]], []byte("/"))
|
||||||
hasAttr := match[6] != match[7]
|
hasAttr := match[6] != match[7]
|
||||||
tagName = strings.ToLower(string(line[match[4]:match[5]]))
|
tagName := strings.ToLower(string(line[match[4]:match[5]]))
|
||||||
_, ok := allowedBlockTags[tagName]
|
_, ok := allowedBlockTags[tagName]
|
||||||
if ok {
|
if ok {
|
||||||
node = ast.NewHTMLBlock(ast.HTMLBlockType6)
|
node = ast.NewHTMLBlock(ast.HTMLBlockType6)
|
||||||
|
|
@ -143,7 +141,7 @@ func (b *htmlBlockParser) Open(parent ast.Node, reader text.Reader, pc Context)
|
||||||
}
|
}
|
||||||
if node == nil {
|
if node == nil {
|
||||||
if match := htmlBlockType6Regexp.FindSubmatchIndex(line); match != nil {
|
if match := htmlBlockType6Regexp.FindSubmatchIndex(line); match != nil {
|
||||||
tagName = string(line[match[2]:match[3]])
|
tagName := string(line[match[2]:match[3]])
|
||||||
_, ok := allowedBlockTags[strings.ToLower(tagName)]
|
_, ok := allowedBlockTags[strings.ToLower(tagName)]
|
||||||
if ok {
|
if ok {
|
||||||
node = ast.NewHTMLBlock(ast.HTMLBlockType6)
|
node = ast.NewHTMLBlock(ast.HTMLBlockType6)
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,7 @@ type ContextConfig struct {
|
||||||
// An ContextOption is a functional option type for the Context.
|
// An ContextOption is a functional option type for the Context.
|
||||||
type ContextOption func(*ContextConfig)
|
type ContextOption func(*ContextConfig)
|
||||||
|
|
||||||
|
// WithIDs is a functional option for the Context.
|
||||||
func WithIDs(ids IDs) ContextOption {
|
func WithIDs(ids IDs) ContextOption {
|
||||||
return func(c *ContextConfig) {
|
return func(c *ContextConfig) {
|
||||||
c.IDs = ids
|
c.IDs = ids
|
||||||
|
|
|
||||||
|
|
@ -826,6 +826,7 @@ type bytesFilter struct {
|
||||||
slots [][][]byte
|
slots [][][]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewBytesFilter returns a new BytesFilter.
|
||||||
func NewBytesFilter(elements ...[]byte) BytesFilter {
|
func NewBytesFilter(elements ...[]byte) BytesFilter {
|
||||||
s := &bytesFilter{
|
s := &bytesFilter{
|
||||||
threshold: 3,
|
threshold: 3,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue