diff --git a/ast/inline.go b/ast/inline.go index 7da098f..8c02d34 100644 --- a/ast/inline.go +++ b/ast/inline.go @@ -91,7 +91,7 @@ func (n *Text) SetSoftLineBreak(v bool) { if v { n.flags |= textSoftLineBreak } else { - n.flags = n.flags &^ textSoftLineBreak + n.flags &^= textSoftLineBreak } } @@ -106,7 +106,7 @@ func (n *Text) SetRaw(v bool) { if v { n.flags |= textRaw } else { - n.flags = n.flags &^ textRaw + n.flags &^= textRaw } } @@ -121,7 +121,7 @@ func (n *Text) SetHardLineBreak(v bool) { if v { n.flags |= textHardLineBreak } else { - n.flags = n.flags &^ textHardLineBreak + n.flags &^= textHardLineBreak } } @@ -237,7 +237,7 @@ func (n *String) SetRaw(v bool) { if v { n.flags |= textRaw } else { - n.flags = n.flags &^ textRaw + n.flags &^= textRaw } } @@ -252,7 +252,7 @@ func (n *String) SetCode(v bool) { if v { n.flags |= textCode } else { - n.flags = n.flags &^ textCode + n.flags &^= textCode } } diff --git a/extension/footnote.go b/extension/footnote.go index 87c017e..1745746 100644 --- a/extension/footnote.go +++ b/extension/footnote.go @@ -229,7 +229,7 @@ func (a *footnoteASTTransformer) Transform(node *gast.Document, reader text.Read } } for footnote := list.FirstChild(); footnote != nil; { - var container gast.Node = footnote + var container = footnote next := footnote.NextSibling() if fc := container.LastChild(); fc != nil && gast.IsParagraph(fc) { container = fc @@ -649,8 +649,8 @@ func applyFootnoteTemplate(b []byte, index, refCount int) []byte { } is := []byte(strconv.Itoa(index)) rs := []byte(strconv.Itoa(refCount)) - ret := bytes.Replace(b, []byte("^^"), is, -1) - return bytes.Replace(ret, []byte("%%"), rs, -1) + ret := bytes.ReplaceAll(b, []byte("^^"), is) + return bytes.ReplaceAll(ret, []byte("%%"), rs) } type footnote struct { diff --git a/extension/linkify.go b/extension/linkify.go index 2f046eb..432bf06 100644 --- a/extension/linkify.go +++ b/extension/linkify.go @@ -182,7 +182,7 @@ func (s *linkifyParser) Parse(parent ast.Node, block text.Reader, pc parser.Cont var m []int var protocol []byte - var typ ast.AutoLinkType = ast.AutoLinkURL + var typ = ast.AutoLinkURL if s.LinkifyConfig.AllowedProtocols == nil { if bytes.HasPrefix(line, protoHTTP) || bytes.HasPrefix(line, protoHTTPS) || bytes.HasPrefix(line, protoFTP) { m = s.LinkifyConfig.URLRegexp.FindSubmatchIndex(line) diff --git a/extension/table.go b/extension/table.go index 48d0d68..30bea17 100644 --- a/extension/table.go +++ b/extension/table.go @@ -175,7 +175,7 @@ func (b *tableParagraphTransformer) Transform(node *gast.Paragraph, reader text. node.Parent().RemoveChild(node.Parent(), node) } else { last := node.Lines().At(i - 2) - last.Stop = last.Stop - 1 // trim last newline(\n) + last.Stop-- // trim last newline(\n) node.Lines().Set(i-2, last) } } diff --git a/parser/auto_link.go b/parser/auto_link.go index 726a505..312e395 100644 --- a/parser/auto_link.go +++ b/parser/auto_link.go @@ -24,7 +24,7 @@ func (s *autoLinkParser) Trigger() []byte { func (s *autoLinkParser) Parse(parent ast.Node, block text.Reader, pc Context) ast.Node { line, segment := block.PeekLine() stop := util.FindEmailIndex(line[1:]) - typ := ast.AutoLinkType(ast.AutoLinkEmail) + typ := ast.AutoLinkEmail if stop < 0 { stop = util.FindURLIndex(line[1:]) typ = ast.AutoLinkURL diff --git a/parser/list.go b/parser/list.go index e5cad11..1a9245f 100644 --- a/parser/list.go +++ b/parser/list.go @@ -147,7 +147,7 @@ func (b *listParser) Open(parent ast.Node, reader text.Reader, pc Context) (ast. if typ == orderedList && start != 1 { return nil, NoChildren } - //an empty list item cannot interrupt a paragraph: + // an empty list item cannot interrupt a paragraph: if match[4] < 0 || util.IsBlank(line[match[4]:match[5]]) { return nil, NoChildren } diff --git a/renderer/renderer.go b/renderer/renderer.go index 10f6d40..fdb6097 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -159,7 +159,7 @@ func (r *renderer) Render(w io.Writer, source []byte, n ast.Node) error { writer = bufio.NewWriter(w) } err := ast.Walk(n, func(n ast.Node, entering bool) (ast.WalkStatus, error) { - s := ast.WalkStatus(ast.WalkContinue) + s := ast.WalkContinue var err error f := r.nodeRendererFuncs[n.Kind()] if f != nil { diff --git a/testutil/testutil.go b/testutil/testutil.go index f7cb312..6bb999f 100644 --- a/testutil/testutil.go +++ b/testutil/testutil.go @@ -156,7 +156,7 @@ func DoTestCaseFile(m goldmark.Markdown, filename string, t TestingT, no ...int) } c.Expected = strings.Join(buf, "\n") if len(c.Expected) != 0 { - c.Expected = c.Expected + "\n" + c.Expected += "\n" } shouldAdd := len(no) == 0 if !shouldAdd { diff --git a/util/util.go b/util/util.go index e9d23a3..8883de9 100644 --- a/util/util.go +++ b/util/util.go @@ -126,13 +126,13 @@ func IsBlank(bs []byte) bool { // VisualizeSpaces visualize invisible space characters. func VisualizeSpaces(bs []byte) []byte { - bs = bytes.Replace(bs, []byte(" "), []byte("[SPACE]"), -1) - bs = bytes.Replace(bs, []byte("\t"), []byte("[TAB]"), -1) - bs = bytes.Replace(bs, []byte("\n"), []byte("[NEWLINE]\n"), -1) - bs = bytes.Replace(bs, []byte("\r"), []byte("[CR]"), -1) - bs = bytes.Replace(bs, []byte("\v"), []byte("[VTAB]"), -1) - bs = bytes.Replace(bs, []byte("\x00"), []byte("[NUL]"), -1) - bs = bytes.Replace(bs, []byte("\ufffd"), []byte("[U+FFFD]"), -1) + bs = bytes.ReplaceAll(bs, []byte(" "), []byte("[SPACE]")) + bs = bytes.ReplaceAll(bs, []byte("\t"), []byte("[TAB]")) + bs = bytes.ReplaceAll(bs, []byte("\n"), []byte("[NEWLINE]\n")) + bs = bytes.ReplaceAll(bs, []byte("\r"), []byte("[CR]")) + bs = bytes.ReplaceAll(bs, []byte("\v"), []byte("[VTAB]")) + bs = bytes.ReplaceAll(bs, []byte("\x00"), []byte("[NUL]")) + bs = bytes.ReplaceAll(bs, []byte("\ufffd"), []byte("[U+FFFD]")) return bs } @@ -573,7 +573,7 @@ func UnescapePunctuations(source []byte) []byte { // ResolveNumericReferences resolve numeric references like 'Ӓ" . func ResolveNumericReferences(source []byte) []byte { cob := NewCopyOnWriteBuffer(source) - buf := make([]byte, 6, 6) + buf := make([]byte, 6) limit := len(source) ok := false n := 0