mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Fix golint issues
This commit is contained in:
parent
2932dadfb3
commit
3dc5ebdb17
7 changed files with 19 additions and 12 deletions
|
|
@ -2,11 +2,13 @@ package fuzz
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/extension"
|
||||
"github.com/yuin/goldmark/renderer/html"
|
||||
)
|
||||
|
||||
// Fuzz runs automated fuzzing against goldmark.
|
||||
func Fuzz(data []byte) int {
|
||||
markdown := goldmark.New(
|
||||
goldmark.WithRendererOptions(
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ package parser
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/yuin/goldmark/ast"
|
||||
"github.com/yuin/goldmark/text"
|
||||
"github.com/yuin/goldmark/util"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var allowedBlockTags = map[string]bool{
|
||||
|
|
@ -97,12 +98,12 @@ var htmlBlockType7Regexp = regexp.MustCompile(`^[ ]{0,3}<(/)?([a-zA-Z0-9]+)(` +
|
|||
type htmlBlockParser struct {
|
||||
}
|
||||
|
||||
var defaultHtmlBlockParser = &htmlBlockParser{}
|
||||
var defaultHTMLBlockParser = &htmlBlockParser{}
|
||||
|
||||
// NewHTMLBlockParser return a new BlockParser that can parse html
|
||||
// blocks.
|
||||
func NewHTMLBlockParser() BlockParser {
|
||||
return defaultHtmlBlockParser
|
||||
return defaultHTMLBlockParser
|
||||
}
|
||||
|
||||
func (b *htmlBlockParser) Trigger() []byte {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ type thematicBreakPraser struct {
|
|||
|
||||
var defaultThematicBreakPraser = &thematicBreakPraser{}
|
||||
|
||||
// NewThematicBreakPraser returns a new BlockParser that
|
||||
// NewThematicBreakParser returns a new BlockParser that
|
||||
// parses thematic breaks.
|
||||
func NewThematicBreakParser() BlockParser {
|
||||
return defaultThematicBreakPraser
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
// Package renderer renders the given AST to certain formats.
|
||||
// Package renderer renders the given AST to certain formats.
|
||||
package renderer
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"io"
|
||||
"sync"
|
||||
|
||||
"github.com/yuin/goldmark/ast"
|
||||
"github.com/yuin/goldmark/util"
|
||||
|
||||
"sync"
|
||||
)
|
||||
|
||||
// A Config struct is a data structure that holds configuration of the Renderer.
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ type TestingT interface {
|
|||
FailNow()
|
||||
}
|
||||
|
||||
// MarkdownTestCase represents a test case.
|
||||
type MarkdownTestCase struct {
|
||||
No int
|
||||
Markdown string
|
||||
|
|
@ -30,6 +31,7 @@ type MarkdownTestCase struct {
|
|||
const attributeSeparator = "//- - - - - - - - -//"
|
||||
const caseSeparator = "//= = = = = = = = = = = = = = = = = = = = = = = =//"
|
||||
|
||||
// DoTestCaseFile runs test cases in a given file.
|
||||
func DoTestCaseFile(m goldmark.Markdown, filename string, t TestingT) {
|
||||
fp, err := os.Open(filename)
|
||||
if err != nil {
|
||||
|
|
@ -86,12 +88,14 @@ func DoTestCaseFile(m goldmark.Markdown, filename string, t TestingT) {
|
|||
DoTestCases(m, cases, t)
|
||||
}
|
||||
|
||||
// DoTestCases runs a set of test cases.
|
||||
func DoTestCases(m goldmark.Markdown, cases []MarkdownTestCase, t TestingT) {
|
||||
for _, testCase := range cases {
|
||||
DoTestCase(m, testCase, t)
|
||||
}
|
||||
}
|
||||
|
||||
// DoTestCase runs a test case.
|
||||
func DoTestCase(m goldmark.Markdown, testCase MarkdownTestCase, t TestingT) {
|
||||
var ok bool
|
||||
var out bytes.Buffer
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
package text
|
||||
|
||||
import (
|
||||
"github.com/yuin/goldmark/util"
|
||||
"io"
|
||||
"regexp"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/yuin/goldmark/util"
|
||||
)
|
||||
|
||||
const invalidValue = -1
|
||||
|
|
@ -138,7 +139,7 @@ func (r *reader) LineOffset() int {
|
|||
if r.source[i] == '\t' {
|
||||
v += util.TabWidth(v)
|
||||
} else {
|
||||
v += 1
|
||||
v++
|
||||
}
|
||||
}
|
||||
r.lineOffset = v - r.pos.Padding
|
||||
|
|
@ -355,7 +356,7 @@ func (r *blockReader) LineOffset() int {
|
|||
if r.source[i] == '\t' {
|
||||
v += util.TabWidth(v)
|
||||
} else {
|
||||
v += 1
|
||||
v++
|
||||
}
|
||||
}
|
||||
r.lineOffset = v - r.pos.Padding
|
||||
|
|
|
|||
|
|
@ -631,7 +631,7 @@ func URLEscape(v []byte, resolveReference bool) []byte {
|
|||
cob.Write(v[n:i])
|
||||
stop := i + int(u8len)
|
||||
if stop > len(v) {
|
||||
i += 1
|
||||
i++
|
||||
n = i
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue