diff options
| author | Shulhan <ms@kilabit.info> | 2023-12-09 23:34:41 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2023-12-09 23:36:50 +0700 |
| commit | f016620361024bb3f5c9709bfdf1e48691439ad4 (patch) | |
| tree | 8e0ca240b3079a4a30369b58be99c877b5226381 | |
| parent | 3d54e38bac45dfe2e33dd0860e4eb49702d9d52e (diff) | |
| download | asciidoctor-go-f016620361024bb3f5c9709bfdf1e48691439ad4.tar.xz | |
all: replace linter golangci-lint with revive and shadow
The golangci-lint does not output any results anymore
Either we are getting good at writing Go or the linter itself is become
less good.
We also have seen that the latest golangci-lint is failed to build
with Go tip, a simple "make" on the golangci-lint never success in my
experiences.
This changes fix all the output reported by the revive and shadow.
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | asciidoctor.go | 2 | ||||
| -rw-r--r-- | asciidoctor_test.go | 4 | ||||
| -rw-r--r-- | document.go | 18 | ||||
| -rw-r--r-- | document_parser.go | 19 | ||||
| -rw-r--r-- | document_test.go | 8 | ||||
| -rw-r--r-- | document_title.go | 1 | ||||
| -rw-r--r-- | element.go | 48 | ||||
| -rw-r--r-- | element_attribute.go | 16 | ||||
| -rw-r--r-- | element_table.go | 2 | ||||
| -rw-r--r-- | html_backend.go | 35 | ||||
| -rw-r--r-- | inline_parser.go | 38 | ||||
| -rw-r--r-- | inline_parser_state.go | 2 | ||||
| -rw-r--r-- | macro.go | 2 | ||||
| -rw-r--r-- | parser.go | 20 | ||||
| -rw-r--r-- | section_counters.go | 2 | ||||
| -rw-r--r-- | table_cell.go | 2 |
17 files changed, 104 insertions, 118 deletions
@@ -6,8 +6,9 @@ all: test lint lint: - -golangci-lint run ./... + -revive ./... -fieldalignment ./... + -shadow ./... test: go test -coverprofile=cover.out ./... diff --git a/asciidoctor.go b/asciidoctor.go index 7e91f40..26ed706 100644 --- a/asciidoctor.go +++ b/asciidoctor.go @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info> // SPDX-License-Identifier: GPL-3.0-or-later -// Package asciidoctor-go is the Go module to parse the [AsciiDoc markup]. +// Package asciidoctor is the Go module to parse the [AsciiDoc markup]. // Its currently support converting the asciidoc to HTML5. // // [AsciiDoc markup]: https://asciidoctor.org/docs/what-is-asciidoc diff --git a/asciidoctor_test.go b/asciidoctor_test.go index 387c5ed..8944165 100644 --- a/asciidoctor_test.go +++ b/asciidoctor_test.go @@ -11,7 +11,7 @@ import ( ) const ( - outputCallHtmlWriteHeader = `htmlWriteHeader` + outputCallHTMLWriteHeader = `htmlWriteHeader` outputCallToHTML = `ToHTML` outputCallToHTMLBody = `ToHTMLBody` ) @@ -58,7 +58,7 @@ func TestData(t *testing.T) { } switch outputCall { - case outputCallHtmlWriteHeader: + case outputCallHTMLWriteHeader: htmlWriteHeader(doc, &bbuf) case outputCallToHTML: err = doc.ToHTML(&bbuf) diff --git a/document.go b/document.go index f716dd9..47d2c85 100644 --- a/document.go +++ b/document.go @@ -134,7 +134,7 @@ func Parse(content []byte) (doc *Document) { func parse(doc *Document, content []byte) { var ( - docp *documentParser = newDocumentParser(doc, content) + docp = newDocumentParser(doc, content) sectLevel string ok bool @@ -206,7 +206,7 @@ func (doc *Document) ToHTML(out io.Writer) (err error) { fmt.Fprintf(buf, "\n<meta name=%q content=%q>", MetaNameAuthor, metaValue) } - var title string = doc.Title.String() + var title = doc.Title.String() if len(title) > 0 { fmt.Fprintf(buf, "\n<title>%s</title>", title) } @@ -413,13 +413,13 @@ func (doc *Document) unpackRawAuthor() { } var ( - rawAuthors []string = strings.Split(doc.rawAuthors, `;`) - authorKey = MetaNameAuthor - emailKey = metaNameEmail - initialsKey = metaNameAuthorInitials - firstNameKey = metaNameFirstName - middleNameKey = metaNameMiddleName - lastNameKey = metaNameLastName + rawAuthors = strings.Split(doc.rawAuthors, `;`) + authorKey = MetaNameAuthor + emailKey = metaNameEmail + initialsKey = metaNameAuthorInitials + firstNameKey = metaNameFirstName + middleNameKey = metaNameMiddleName + lastNameKey = metaNameLastName author *Author rawAuthor string diff --git a/document_parser.go b/document_parser.go index baeb82e..d165ff9 100644 --- a/document_parser.go +++ b/document_parser.go @@ -157,9 +157,7 @@ func (docp *documentParser) hasPreamble() bool { } func (docp *documentParser) include(el *elementInclude) { - var ( - content []byte = bytes.ReplaceAll(el.content, []byte("\r\n"), []byte("\n")) - ) + var content = bytes.ReplaceAll(el.content, []byte("\r\n"), []byte("\n")) content = bytes.TrimRight(content, "\n") @@ -351,9 +349,7 @@ func (docp *documentParser) parseBlock(parent *element, term int) { continue case lineKindInclude: - var ( - elInclude *elementInclude = parseInclude(docp.doc, []byte(line)) - ) + var elInclude = parseInclude(docp.doc, []byte(line)) if elInclude == nil { el.Write(line) @@ -466,7 +462,7 @@ func (docp *documentParser) parseBlock(parent *element, term int) { // BUG: "= =a" could become "a", it should be "=a" el.Write(bytes.TrimLeft(line, "= \t")) - var isDiscrete bool = el.style&styleSectionDiscrete > 0 + var isDiscrete = el.style&styleSectionDiscrete > 0 if isDiscrete { el.kind = elKindSectionDiscrete el.level = docp.kind @@ -588,7 +584,7 @@ func (docp *documentParser) parseBlock(parent *element, term int) { continue case elKindBlockImage: - var lineImage []byte = bytes.TrimRight(line[7:], " \t") + var lineImage = bytes.TrimRight(line[7:], " \t") if el.parseBlockImage(docp.doc, lineImage) { el.kind = docp.kind line = nil @@ -690,8 +686,8 @@ func (docp *documentParser) parseHeader() { ) var ( - logp = `parseHeader` - state int = stateBegin + logp = `parseHeader` + state = stateBegin key string value string @@ -942,7 +938,6 @@ func (docp *documentParser) parseListDescription(parent, el *element, line []byt continue } if docp.kind == lineKindListContinue { - var el *element el, line = docp.parseListBlock() if el != nil { listItem.addChild(el) @@ -976,7 +971,7 @@ func (docp *documentParser) parseListDescription(parent, el *element, line []byt continue } - var parentListItem *element = parent + var parentListItem = parent for parentListItem != nil { if parentListItem.kind == docp.kind && parentListItem.level == el.level { diff --git a/document_test.go b/document_test.go index f36be73..7fc692f 100644 --- a/document_test.go +++ b/document_test.go @@ -100,18 +100,18 @@ func TestDocument_ToHTML(t *testing.T) { type testCase struct { name string fileAdoc string - fileExpHtml string + fileExpHTML string } var ( cases = []testCase{{ name: `header`, fileAdoc: `testdata/html/header.adoc`, - fileExpHtml: `testdata/html/header.exp.html`, + fileExpHTML: `testdata/html/header.exp.html`, }, { name: `preamble`, fileAdoc: `testdata/html/preamble.adoc`, - fileExpHtml: `testdata/html/preamble.exp.html`, + fileExpHTML: `testdata/html/preamble.exp.html`, }} c testCase @@ -138,7 +138,7 @@ func TestDocument_ToHTML(t *testing.T) { t.Fatal(err) } - exp, err = os.ReadFile(c.fileExpHtml) + exp, err = os.ReadFile(c.fileExpHTML) if err != nil { t.Fatal(err) } diff --git a/document_title.go b/document_title.go index 9312fd4..55b2419 100644 --- a/document_title.go +++ b/document_title.go @@ -5,6 +5,7 @@ package asciidoctor import "fmt" +// DocumentTitle contains the main and optional sub title. type DocumentTitle struct { el *element @@ -82,8 +82,8 @@ func (el *element) getListOrderedType() string { // getVideoSource generate video full URL for HTML attribute `src`. func (el *element) getVideoSource() string { var ( - u = new(url.URL) - src string = el.Attrs[attrNameSrc] + u = new(url.URL) + src = el.Attrs[attrNameSrc] q []string fragment string @@ -239,7 +239,7 @@ func (el *element) addChild(child *element) { if el.child == nil { el.child = child } else { - var c *element = el.child + var c = el.child for c.next != nil { c = c.next } @@ -250,7 +250,7 @@ func (el *element) addChild(child *element) { // backTrimSpace remove trailing white spaces on raw field. func (el *element) backTrimSpace() { - var x int = len(el.raw) - 1 + var x = len(el.raw) - 1 for ; x > 0; x-- { if ascii.IsSpace(el.raw[x]) { continue @@ -277,17 +277,17 @@ func (el *element) lastSuccessor() (last *element) { func (el *element) parseBlockAudio(doc *Document, line []byte) bool { line = bytes.TrimRight(line[7:], " \t") - var attrBegin int = bytes.IndexByte(line, '[') + var attrBegin = bytes.IndexByte(line, '[') if attrBegin < 0 { return false } - var attrEnd int = bytes.IndexByte(line, ']') + var attrEnd = bytes.IndexByte(line, ']') if attrEnd < 0 { return false } - var src []byte = bytes.TrimRight(line[:attrBegin], " \t") + var src = bytes.TrimRight(line[:attrBegin], " \t") if el.Attrs == nil { el.Attrs = make(map[string]string) } @@ -303,7 +303,7 @@ func (el *element) parseBlockAudio(doc *Document, line []byte) bool { // The line parameter must not have "image::" block or "image:" macro prefix. func (el *element) parseBlockImage(doc *Document, line []byte) bool { var ( - attrBegin int = bytes.IndexByte(line, '[') + attrBegin = bytes.IndexByte(line, '[') attr string key string @@ -398,7 +398,7 @@ func (el *element) parseInlineMarkup(doc *Document, kind int) { return } - var container *element = parseInlineMarkup(doc, el.raw) + var container = parseInlineMarkup(doc, el.raw) if kind != 0 { container.kind = kind } @@ -414,9 +414,9 @@ func (el *element) parseInlineMarkup(doc *Document, kind int) { func (el *element) parseLineAdmonition(line []byte) { var ( - sep int = bytes.IndexByte(line, ':') - class string = string(bytes.ToLower(line[:sep])) - rawLabel string = admonitionToLabel(class) + sep = bytes.IndexByte(line, ':') + class = string(bytes.ToLower(line[:sep])) + rawLabel = admonitionToLabel(class) ) el.addRole(class) @@ -544,7 +544,7 @@ func (el *element) parseSection(doc *Document, isDiscrete bool) { } var ( - container *element = parseInlineMarkup(doc, el.raw) + container = parseInlineMarkup(doc, el.raw) lastChild *element p *element @@ -652,7 +652,7 @@ func (el *element) parseBlockVideo(doc *Document, line []byte) bool { func (el *element) postParseList(doc *Document, kind int) { var ( - item *element = el.child + item = el.child raw []byte ) @@ -682,9 +682,7 @@ func (el *element) postParseParagraph(parent *element) { el.raw = bytes.TrimRight(el.raw, " \t\n") - var ( - lines [][]byte = bytes.Split(el.raw, []byte{'\n'}) - ) + var lines = bytes.Split(el.raw, []byte{'\n'}) if len(lines) <= 1 { return @@ -695,7 +693,7 @@ func (el *element) postParseParagraph(parent *element) { func (el *element) postParseParagraphAsQuote(lines [][]byte) bool { var ( - lastLine []byte = lines[len(lines)-1] + lastLine = lines[len(lines)-1] firstLine []byte secondLastLine []byte @@ -746,10 +744,11 @@ func (el *element) postParseParagraphAsQuote(lines [][]byte) bool { } el.kind = elKindBlockExcerpts - var opts []string = strings.SplitN(string(lastLine[3:]), `,`, 2) if el.Attrs == nil { el.Attrs = make(map[string]string) } + + var opts = strings.SplitN(string(lastLine[3:]), `,`, 2) if len(opts) >= 1 { el.Attrs[attrNameAttribution] = strings.TrimSpace(opts[0]) } @@ -771,7 +770,7 @@ func (el *element) removeLastIfEmpty() { if el.child == nil { return } - var c *element = el + var c = el for c.child != nil { c = c.child for c.next != nil { @@ -796,7 +795,8 @@ func (el *element) removeLastIfEmpty() { func (el *element) setStyleAdmonition(admName string) { admName = strings.ToLower(admName) el.addRole(admName) - var rawLabel string = admonitionToLabel(admName) + + var rawLabel = admonitionToLabel(admName) el.rawLabel.WriteString(rawLabel) } @@ -807,9 +807,9 @@ func (el *element) toHTML(doc *Document, w io.Writer) { case elKindCrossReference: var ( - href string = el.Attrs[attrNameHref] - label = string(el.raw) - anchor *anchor = doc.anchors[href] + href = el.Attrs[attrNameHref] + label = string(el.raw) + anchor = doc.anchors[href] ) if anchor == nil { href = doc.titleID[href] diff --git a/element_attribute.go b/element_attribute.go index d08538d..0d46b8b 100644 --- a/element_attribute.go +++ b/element_attribute.go @@ -135,15 +135,15 @@ func (ea *elementAttribute) parseElementAttribute(raw []byte) { } } -func (ea *elementAttribute) parseNamedValue(prevc byte, str string) { +func (ea *elementAttribute) parseNamedValue(str string) { if ea.Attrs == nil { ea.Attrs = make(map[string]string) } var ( - kv []string = strings.Split(str, `=`) - key = kv[0] - val = strings.TrimSpace(kv[1]) + kv = strings.Split(str, `=`) + key = kv[0] + val = strings.TrimSpace(kv[1]) ) if len(val) == 0 { @@ -158,8 +158,8 @@ func (ea *elementAttribute) parseNamedValue(prevc byte, str string) { } var ( - rawvals []string = strings.Split(val, `,`) - vals = make([]string, 0, len(rawvals)) + rawvals = strings.Split(val, `,`) + vals = make([]string, 0, len(rawvals)) v string ) @@ -186,7 +186,7 @@ func (ea *elementAttribute) setByPreviousChar(prevc byte, str string) { switch prevc { case 0: if strings.IndexByte(str, '=') > 0 { - ea.parseNamedValue(prevc, str) + ea.parseNamedValue(str) } else { ea.rawStyle = str ea.style = parseStyle(str) @@ -199,7 +199,7 @@ func (ea *elementAttribute) setByPreviousChar(prevc byte, str string) { ea.options = append(ea.options, str) case ',': if strings.IndexByte(str, '=') > 0 { - ea.parseNamedValue(prevc, str) + ea.parseNamedValue(str) } else { if ea.Attrs == nil { ea.Attrs = make(map[string]string) diff --git a/element_table.go b/element_table.go index 2c0fb42..53aaf03 100644 --- a/element_table.go +++ b/element_table.go @@ -310,7 +310,7 @@ func parseAttrCols(val string) (ncols int, formats []*columnFormat) { // parseToRawRows convert raw table content into multiple raw rows. func parseToRawRows(raw []byte) (rows [][]byte) { var ( - lines [][]byte = bytes.Split(raw, []byte{'\n'}) + lines = bytes.Split(raw, []byte{'\n'}) line []byte ) diff --git a/html_backend.go b/html_backend.go index f3a285d..94f0ed7 100644 --- a/html_backend.go +++ b/html_backend.go @@ -582,8 +582,8 @@ func htmlWriteBlockBegin(el *element, out io.Writer, addClass string) { } var ( - classes string = el.htmlClasses() - c string = strings.TrimSpace(addClass + ` ` + classes) + classes = el.htmlClasses() + c = strings.TrimSpace(addClass + ` ` + classes) ) if len(c) > 0 { @@ -608,9 +608,7 @@ func htmlWriteBlockAdmonition(el *element, out io.Writer) { fmt.Fprint(out, "\n<table>\n<tr>\n<td class=\"icon\">") - var ( - iconsFont string = el.Attrs[attrNameIcons] - ) + var iconsFont = el.Attrs[attrNameIcons] if iconsFont == attrValueFont { fmt.Fprintf(out, _htmlAdmonitionIconsFont, @@ -630,8 +628,8 @@ func htmlWriteBlockAdmonition(el *element, out io.Writer) { func htmlWriteBlockAudio(el *element, out io.Writer) { var ( - optControls string = ` controls` - src string = el.Attrs[attrNameSrc] + optControls = ` controls` + src = el.Attrs[attrNameSrc] optAutoplay string optLoop string @@ -1078,8 +1076,8 @@ func htmlWriteInlineImage(el *element, out io.Writer) { } var ( - src string = el.Attrs[attrNameSrc] - alt string = el.Attrs[attrNameAlt] + src = el.Attrs[attrNameSrc] + alt = el.Attrs[attrNameAlt] width string height string @@ -1105,9 +1103,8 @@ func htmlWriteInlineImage(el *element, out io.Writer) { } func htmlWriteInlinePass(doc *Document, el *element, out io.Writer) { - var ( - text []byte = htmlSubs(doc, el) - ) + var text = htmlSubs(doc, el) + fmt.Fprint(out, string(text)) } @@ -1139,8 +1136,8 @@ func htmlWriteListDescriptionEnd(el *element, out io.Writer) { func htmlWriteListOrdered(el *element, out io.Writer) { var ( - class string = el.getListOrderedClass() - tipe string = el.getListOrderedType() + class = el.getListOrderedClass() + tipe = el.getListOrderedType() ) if len(tipe) > 0 { @@ -1254,7 +1251,7 @@ func hmltWriteSectionDiscrete(doc *Document, el *element, out io.Writer) { func htmlWriteTable(doc *Document, el *element, out io.Writer) { var ( - table *elementTable = el.table + table = el.table footer *tableRow format *columnFormat @@ -1305,7 +1302,7 @@ func htmlWriteTable(doc *Document, el *element, out io.Writer) { fmt.Fprint(out, "\n</colgroup>") var ( - rows []*tableRow = table.rows + rows = table.rows row *tableRow ) @@ -1504,9 +1501,9 @@ func htmlWriteURLBegin(el *element, out io.Writer) { fmt.Fprintf(out, "<a href=\"%s\"", el.Attrs[attrNameHref]) var ( - classes string = el.htmlClasses() - target string = el.Attrs[attrNameTarget] - rel string = el.Attrs[attrNameRel] + classes = el.htmlClasses() + target = el.Attrs[attrNameTarget] + rel = el.Attrs[attrNameRel] ) if len(classes) > 0 { diff --git a/inline_parser.go b/inline_parser.go index 0e280d7..d5518e6 100644 --- a/inline_parser.go +++ b/inline_parser.go @@ -201,14 +201,12 @@ func (pi *inlineParser) do() { } } if pi.nextc == '"' { - if pi.parseQuoteEnd([]byte("`\""), - elKindSymbolQuoteDoubleEnd) { + if pi.parseQuoteEnd(elKindSymbolQuoteDoubleEnd) { continue } } if pi.nextc == '\'' { - if pi.parseQuoteEnd([]byte("`'"), - elKindSymbolQuoteSingleEnd) { + if pi.parseQuoteEnd(elKindSymbolQuoteSingleEnd) { continue } @@ -399,7 +397,7 @@ func (pi *inlineParser) escape() { func (pi *inlineParser) parseCrossRef() bool { var ( - raw []byte = pi.content[pi.x+2:] + raw = pi.content[pi.x+2:] idx int ) @@ -447,7 +445,7 @@ func (pi *inlineParser) parseCrossRef() bool { // parseInlineID parse the ID and optional label between "[[" "]]". func (pi *inlineParser) parseInlineID() bool { var ( - raw []byte = pi.content[pi.x+2:] + raw = pi.content[pi.x+2:] el *element stringID string @@ -490,7 +488,7 @@ func (pi *inlineParser) parseInlineID() bool { // "#". func (pi *inlineParser) parseInlineIDShort() bool { var ( - raw []byte = pi.content[pi.x+2:] + raw = pi.content[pi.x+2:] el *element stringID string @@ -537,14 +535,14 @@ func (pi *inlineParser) parseQuoteBegin(quoteEnd []byte, kind int) bool { return false } - var c byte = pi.content[pi.x+2] + var c = pi.content[pi.x+2] if ascii.IsSpace(c) { return false } var ( - raw []byte = pi.content[pi.x+2:] - idx int = bytes.LastIndex(raw, quoteEnd) + raw = pi.content[pi.x+2:] + idx = bytes.LastIndex(raw, quoteEnd) ) if idx < 0 { @@ -564,7 +562,7 @@ func (pi *inlineParser) parseQuoteBegin(quoteEnd []byte, kind int) bool { return true } -func (pi *inlineParser) parseQuoteEnd(quoteEnd []byte, kind int) bool { +func (pi *inlineParser) parseQuoteEnd(kind int) bool { if ascii.IsSpace(pi.prev) { // This is not the end that we looking for. return false @@ -599,7 +597,7 @@ func (pi *inlineParser) parseFormat(kind int, style int64) bool { } var ( - raw []byte = pi.content[pi.x+1:] + raw = pi.content[pi.x+1:] el *element idx int @@ -665,7 +663,7 @@ func (pi *inlineParser) parseFormatUnconstrained( // Do we have the end format? var ( - raw []byte = pi.content[pi.x+2:] + raw = pi.content[pi.x+2:] el *element ) @@ -828,7 +826,7 @@ func (pi *inlineParser) parsePassthrough() bool { func (pi *inlineParser) parsePassthroughDouble() bool { var ( - raw []byte = pi.content[pi.x+2:] + raw = pi.content[pi.x+2:] idx int el *element ) @@ -852,7 +850,7 @@ func (pi *inlineParser) parsePassthroughDouble() bool { func (pi *inlineParser) parsePassthroughTriple() bool { var ( - raw []byte = pi.content[pi.x+3:] + raw = pi.content[pi.x+3:] idx int el *element ) @@ -1002,7 +1000,7 @@ func parseURL(doc *Document, scheme string, content []byte) (el *element, n int) n = x + idx + 2 - var attr []byte = content[x : x+idx+1] + var attr = content[x : x+idx+1] el.style = styleLink el.parseElementAttribute(attr) if len(el.Attrs) == 0 { @@ -1012,7 +1010,7 @@ func parseURL(doc *Document, scheme string, content []byte) (el *element, n int) } if len(el.rawStyle) >= 1 { var ( - l int = len(el.rawStyle) + l = len(el.rawStyle) child *element ) @@ -1030,8 +1028,8 @@ func parseURL(doc *Document, scheme string, content []byte) (el *element, n int) func (pi *inlineParser) terminate(kind int, style int64) { var ( - el *element = pi.current - stateTmp = &inlineParserState{} + el = pi.current + stateTmp = &inlineParserState{} ) for el.parent != nil { @@ -1111,7 +1109,7 @@ func indexByteUnescape(in []byte, c byte) (out []byte, idx int) { func indexUnescape(in []byte, token []byte) (out []byte, idx int) { var ( - tokenLen int = len(token) + tokenLen = len(token) tmp []byte x int diff --git a/inline_parser_state.go b/inline_parser_state.go index 783faf6..9f52502 100644 --- a/inline_parser_state.go +++ b/inline_parser_state.go @@ -12,7 +12,7 @@ func (pis *inlineParserState) push(c int) { } func (pis *inlineParserState) pop() (c int) { - var size int = len(pis.stack) + var size = len(pis.stack) if size > 0 { c = pis.stack[size-1] pis.stack = pis.stack[:size-1] @@ -61,7 +61,7 @@ type macro struct { // If macro name and value valid it will return the element for that macro. func parseMacroName(textBefore []byte) (macroName string) { var ( - x int = len(textBefore) - 1 + x = len(textBefore) - 1 ok bool ) @@ -292,7 +292,7 @@ const ( symbolUnchecked = `❏` ) -var adocStyles map[string]int64 = map[string]int64{ +var adocStyles = map[string]int64{ `colophon`: styleSectionColophon, `abstract`: styleSectionAbstract, `preface`: styleSectionPreface, @@ -330,7 +330,7 @@ var adocStyles map[string]int64 = map[string]int64{ `verse`: styleVerse, } -var _attrRef map[string]string = map[string]string{ +var _attrRef = map[string]string{ `amp`: `&`, `apos`: htmlSymbolSingleQuote, // ' `asterisk`: `*`, @@ -668,9 +668,7 @@ func parseClosedBracket(input []byte, openb, closedb byte) (out []byte, idx int) // parseIDLabel parse the string "ID (,LABEL)" into ID and label. // It will return empty id and label if ID is not valid. func parseIDLabel(s []byte) (id, label []byte) { - var ( - idLabel [][]byte = bytes.Split(s, []byte(`,`)) - ) + var idLabel = bytes.Split(s, []byte(`,`)) id = idLabel[0] if len(idLabel) >= 2 { @@ -683,9 +681,7 @@ func parseIDLabel(s []byte) (id, label []byte) { } func parseInlineMarkup(doc *Document, content []byte) (container *element) { - var ( - pi *inlineParser = newInlineParser(doc, content) - ) + var pi = newInlineParser(doc, content) pi.do() return pi.container @@ -818,8 +814,8 @@ func whatKindOfLine(line []byte) (kind int, spaces, got []byte) { kind = lineKindAttribute } else if line[0] == '[' { var ( - newline []byte = bytes.TrimRight(line, " \t") - l int = len(newline) + newline = bytes.TrimRight(line, " \t") + l = len(newline) ) if newline[l-1] != ']' { @@ -843,9 +839,7 @@ func whatKindOfLine(line []byte) (kind int, spaces, got []byte) { } return lineKindAttributeElement, spaces, line } else if line[0] == '=' { - var ( - subs [][]byte = bytes.Fields(line) - ) + var subs = bytes.Fields(line) if bytes.Equal(subs[0], []byte(`==`)) { kind = elKindSectionL1 diff --git a/section_counters.go b/section_counters.go index 8dff0e0..0a5ba86 100644 --- a/section_counters.go +++ b/section_counters.go @@ -33,7 +33,7 @@ func (sec *sectionCounters) set(level int) *sectionCounters { sec.nums[level]++ sec.curr = level } - var clone sectionCounters = *sec + var clone = *sec return &clone } diff --git a/table_cell.go b/table_cell.go index ca75cba..2d1627b 100644 --- a/table_cell.go +++ b/table_cell.go @@ -17,7 +17,7 @@ func (tc *tableCell) writeByte(b byte) { } func (tc *tableCell) endWithLF() bool { - var l int = len(tc.content) + var l = len(tc.content) if l == 0 { return false } |
