From d90e37e0c6e812f9913bf256c9c81aa05b7a08aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 2 Dec 2020 13:23:25 +0100 Subject: all: Format code with gofumpt See https://github.com/mvdan/gofumpt --- markup/asciidocext/convert.go | 3 +-- markup/asciidocext/convert_test.go | 1 - markup/blackfriday/convert.go | 2 -- markup/blackfriday/convert_test.go | 2 +- markup/converter/converter.go | 4 +--- markup/goldmark/autoid.go | 1 - markup/goldmark/autoid_test.go | 4 ---- markup/goldmark/convert.go | 7 +------ markup/goldmark/convert_test.go | 4 ---- markup/goldmark/render_hooks.go | 2 -- markup/goldmark/toc_test.go | 3 ++- markup/highlight/config.go | 4 +--- markup/highlight/config_test.go | 2 -- markup/highlight/highlight_test.go | 2 -- markup/internal/external.go | 1 - markup/markup.go | 2 +- markup/markup_config/config.go | 1 - markup/markup_config/config_test.go | 1 - markup/markup_test.go | 1 - markup/mmark/convert.go | 3 --- markup/mmark/convert_test.go | 2 +- markup/pandoc/convert.go | 1 - markup/rst/convert.go | 2 +- markup/tableofcontents/tableofcontents.go | 2 +- markup/tableofcontents/tableofcontents_test.go | 1 - 25 files changed, 11 insertions(+), 47 deletions(-) (limited to 'markup') diff --git a/markup/asciidocext/convert.go b/markup/asciidocext/convert.go index a92b6f9e3..e2e5b7865 100644 --- a/markup/asciidocext/convert.go +++ b/markup/asciidocext/convert.go @@ -96,7 +96,7 @@ func (a *asciidocConverter) getAsciidocContent(src []byte, ctx converter.Documen } func (a *asciidocConverter) parseArgs(ctx converter.DocumentContext) []string { - var cfg = a.cfg.MarkupConfig.AsciidocExt + cfg := a.cfg.MarkupConfig.AsciidocExt args := []string{} args = a.appendArg(args, "-b", cfg.Backend, asciidocext_config.CliDefault.Backend, asciidocext_config.AllowedBackend) @@ -137,7 +137,6 @@ func (a *asciidocConverter) parseArgs(ctx converter.DocumentContext) []string { file := filepath.Base(ctx.Filename) if a.cfg.Cfg.GetBool("uglyUrls") || file == "_index.adoc" || file == "index.adoc" { outDir, err = filepath.Abs(filepath.Dir(filepath.Join(destinationDir, ctx.DocumentName))) - } else { postDir := "" page, ok := ctx.Document.(pageSubset) diff --git a/markup/asciidocext/convert_test.go b/markup/asciidocext/convert_test.go index 0e7c93c45..fa3aef404 100644 --- a/markup/asciidocext/convert_test.go +++ b/markup/asciidocext/convert_test.go @@ -246,7 +246,6 @@ func TestAsciidoctorAttributes(t *testing.T) { c.Assert(args[2], qt.Equals, "-a") c.Assert(expectedValues[args[3]], qt.Equals, true) c.Assert(args[4], qt.Equals, "--no-header-footer") - } func TestConvert(t *testing.T) { diff --git a/markup/blackfriday/convert.go b/markup/blackfriday/convert.go index d844c5554..b786e29de 100644 --- a/markup/blackfriday/convert.go +++ b/markup/blackfriday/convert.go @@ -52,7 +52,6 @@ func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) cfg: cfg, }, nil }), nil - } type blackfridayConverter struct { @@ -125,7 +124,6 @@ func (c *blackfridayConverter) getHTMLRenderer(renderTOC bool) blackfriday.Rende } func getFlags(renderTOC bool, cfg blackfriday_config.Config) int { - var flags int if renderTOC { diff --git a/markup/blackfriday/convert_test.go b/markup/blackfriday/convert_test.go index d2d8d927e..414905a76 100644 --- a/markup/blackfriday/convert_test.go +++ b/markup/blackfriday/convert_test.go @@ -129,7 +129,7 @@ func TestGetAllFlags(t *testing.T) { actualFlags := getFlags(false, b) var expectedFlags int - //OR-ing flags together... + // OR-ing flags together... for _, d := range allFlags { expectedFlags |= d.testFlag } diff --git a/markup/converter/converter.go b/markup/converter/converter.go index 231527441..d7e3d4639 100644 --- a/markup/converter/converter.go +++ b/markup/converter/converter.go @@ -130,6 +130,4 @@ type RenderContext struct { RenderHooks *hooks.Renderers } -var ( - FeatureRenderHooks = identity.NewPathIdentity("markup", "renderingHooks") -) +var FeatureRenderHooks = identity.NewPathIdentity("markup", "renderingHooks") diff --git a/markup/goldmark/autoid.go b/markup/goldmark/autoid.go index 1ca1ba5e0..04313269c 100644 --- a/markup/goldmark/autoid.go +++ b/markup/goldmark/autoid.go @@ -125,7 +125,6 @@ func (ids *idFactory) Generate(value []byte, kind ast.NodeKind) []byte { } ids.vals[buf.String()] = struct{}{} - }) } diff --git a/markup/goldmark/autoid_test.go b/markup/goldmark/autoid_test.go index 7acae9f47..0bdb63c12 100644 --- a/markup/goldmark/autoid_test.go +++ b/markup/goldmark/autoid_test.go @@ -91,7 +91,6 @@ func TestSanitizeAnchorNameAsciiOnly(t *testing.T) { c.Assert(sanitizeAnchorNameString("god is神真美好 good", goldmark_config.AutoHeadingIDTypeGitHubAscii), qt.Equals, "god-is-good") c.Assert(sanitizeAnchorNameString("Resumé", goldmark_config.AutoHeadingIDTypeGitHubAscii), qt.Equals, "resume") - } func TestSanitizeAnchorNameBlackfriday(t *testing.T) { @@ -106,7 +105,6 @@ func BenchmarkSanitizeAnchorName(b *testing.B) { result := sanitizeAnchorName(input, goldmark_config.AutoHeadingIDTypeGitHub) if len(result) != 24 { b.Fatalf("got %d", len(result)) - } } } @@ -118,7 +116,6 @@ func BenchmarkSanitizeAnchorNameAsciiOnly(b *testing.B) { result := sanitizeAnchorName(input, goldmark_config.AutoHeadingIDTypeGitHubAscii) if len(result) != 12 { b.Fatalf("got %d", len(result)) - } } } @@ -130,7 +127,6 @@ func BenchmarkSanitizeAnchorNameBlackfriday(b *testing.B) { result := sanitizeAnchorName(input, goldmark_config.AutoHeadingIDTypeBlackfriday) if len(result) != 24 { b.Fatalf("got %d", len(result)) - } } } diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go index 2a66cc184..50e7bcb8a 100644 --- a/markup/goldmark/convert.go +++ b/markup/goldmark/convert.go @@ -62,9 +62,7 @@ func (p provide) New(cfg converter.ProviderConfig) (converter.Provider, error) { }), nil } -var ( - _ converter.AnchorNameSanitizer = (*goldmarkConverter)(nil) -) +var _ converter.AnchorNameSanitizer = (*goldmarkConverter)(nil) type goldmarkConverter struct { md goldmark.Markdown @@ -156,7 +154,6 @@ func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown { ) return md - } var _ identity.IdentitiesProvider = (*converterResult)(nil) @@ -267,7 +264,6 @@ func (c *goldmarkConverter) Convert(ctx converter.RenderContext) (result convert ids: rcx.ids.GetIdentities(), toc: pctx.TableOfContents(), }, nil - } var featureSet = map[identity.Identity]bool{ @@ -329,7 +325,6 @@ func newHighlighting(cfg highlight.Config) goldmark.Extender { } w.WriteString("") - }), ) } diff --git a/markup/goldmark/convert_test.go b/markup/goldmark/convert_test.go index 984adef0d..f105afdc4 100644 --- a/markup/goldmark/convert_test.go +++ b/markup/goldmark/convert_test.go @@ -31,7 +31,6 @@ import ( ) func convert(c *qt.C, mconf markup_config.Config, content string) converter.Result { - p, err := Provider.New( converter.ProviderConfig{ MarkupConfig: mconf, @@ -163,7 +162,6 @@ description c.Assert(ok, qt.Equals, true) tocHTML := toc.TableOfContents().ToHTML(1, 2, false) c.Assert(tocHTML, qt.Contains, "TableOfContents") - } func TestConvertAutoIDAsciiOnly(t *testing.T) { @@ -212,7 +210,6 @@ func TestConvertIssues(t *testing.T) { c.Assert(got, qt.Contains, "\n
This will be \"slotted\" into the custom element.
\n
\n") }) - } func TestCodeFence(t *testing.T) { @@ -257,7 +254,6 @@ LINE5 `) result = convertForConfig(c, cfg, `echo "Hugo Rocks!"`, "unknown") c.Assert(result, qt.Equals, "
echo "Hugo Rocks!"\n
") - }) c.Run("Highlight lines, default config", func(c *qt.C) { diff --git a/markup/goldmark/render_hooks.go b/markup/goldmark/render_hooks.go index c541cbba4..f17e4e139 100644 --- a/markup/goldmark/render_hooks.go +++ b/markup/goldmark/render_hooks.go @@ -115,7 +115,6 @@ func (r *hookedRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) // https://github.com/yuin/goldmark/blob/b611cd333a492416b56aa8d94b04a67bf0096ab2/renderer/html/html.go#L404 func (r *hookedRenderer) RenderAttributes(w util.BufWriter, node ast.Node) { - for _, attr := range node.Attributes() { _, _ = w.WriteString(" ") _, _ = w.Write(attr.Name) @@ -189,7 +188,6 @@ func (r *hookedRenderer) renderImage(w util.BufWriter, source []byte, node ast.N ctx.AddIdentity(h.ImageRenderer) return ast.WalkContinue, err - } // Fall back to the default Goldmark render funcs. Method below borrowed from: diff --git a/markup/goldmark/toc_test.go b/markup/goldmark/toc_test.go index 464441335..f8fcf79d4 100644 --- a/markup/goldmark/toc_test.go +++ b/markup/goldmark/toc_test.go @@ -53,7 +53,8 @@ And then some. p, err := Provider.New( converter.ProviderConfig{ MarkupConfig: markup_config.Default, - Logger: loggers.NewErrorLogger()}) + Logger: loggers.NewErrorLogger(), + }) c.Assert(err, qt.IsNil) conv, err := p.New(converter.DocumentContext{}) c.Assert(err, qt.IsNil) diff --git a/markup/highlight/config.go b/markup/highlight/config.go index a7c5ab4cb..1bee58dc5 100644 --- a/markup/highlight/config.go +++ b/markup/highlight/config.go @@ -71,7 +71,7 @@ func (cfg Config) ToHTMLOptions() []html.Option { if cfg.LineAnchors != "" { lineAnchors = cfg.LineAnchors + "-" } - var options = []html.Option{ + options := []html.Option{ html.TabWidth(cfg.TabWidth), html.WithLineNumbers(cfg.LineNos), html.BaseLineNumber(cfg.LineNoStart), @@ -126,7 +126,6 @@ func ApplyLegacyConfig(cfg config.Provider, conf *Config) error { } return nil - } func parseOptions(in string) (map[string]interface{}, error) { @@ -199,5 +198,4 @@ func hlLinesToRanges(startLine int, s string) ([][2]int, error) { ranges = append(ranges, r) } return ranges, nil - } diff --git a/markup/highlight/config_test.go b/markup/highlight/config_test.go index 0d4bb2f97..3c3747622 100644 --- a/markup/highlight/config_test.go +++ b/markup/highlight/config_test.go @@ -40,7 +40,6 @@ func TestConfig(t *testing.T) { c.Assert(cfg.CodeFences, qt.Equals, false) c.Assert(cfg.LineNos, qt.Equals, true) c.Assert(cfg.LineNumbersInTable, qt.Equals, false) - }) c.Run("parseOptions", func(c *qt.C) { @@ -54,6 +53,5 @@ func TestConfig(t *testing.T) { c.Assert(cfg.LineNumbersInTable, qt.Equals, false) c.Assert(cfg.LineNoStart, qt.Equals, 32) c.Assert(cfg.Hl_Lines, qt.Equals, "3-8 10-20") - }) } diff --git a/markup/highlight/highlight_test.go b/markup/highlight/highlight_test.go index 228d5e8c9..eb8ba3e96 100644 --- a/markup/highlight/highlight_test.go +++ b/markup/highlight/highlight_test.go @@ -46,7 +46,6 @@ User-Agent: foo c.Assert(result, qt.Equals, `
echo "Hugo Rocks!"
`) result, _ = h.Highlight(`echo "Hugo Rocks!"`, "unknown", "") c.Assert(result, qt.Equals, `
echo "Hugo Rocks!"
`) - }) c.Run("Highlight lines, default config", func(c *qt.C) { @@ -147,5 +146,4 @@ User-Agent: foo c.Assert(result, qt.Contains, "hello") c.Assert(result, qt.Contains, "}") }) - } diff --git a/markup/internal/external.go b/markup/internal/external.go index fc7fddb23..e8f86ae94 100644 --- a/markup/internal/external.go +++ b/markup/internal/external.go @@ -12,7 +12,6 @@ func ExternallyRenderContent( cfg converter.ProviderConfig, ctx converter.DocumentContext, content []byte, path string, args []string) []byte { - logger := cfg.Logger cmd := exec.Command(path, args...) cmd.Stdin = bytes.NewReader(content) diff --git a/markup/markup.go b/markup/markup.go index dd4148128..31fa6b0f7 100644 --- a/markup/markup.go +++ b/markup/markup.go @@ -97,7 +97,7 @@ func NewConverterProvider(cfg converter.ProviderConfig) (ConverterProvider, erro type ConverterProvider interface { Get(name string) converter.Provider - //Default() converter.Provider + // Default() converter.Provider GetMarkupConfig() markup_config.Config Highlight(code, lang, optsStr string) (string, error) } diff --git a/markup/markup_config/config.go b/markup/markup_config/config.go index a42556c2b..376350c95 100644 --- a/markup/markup_config/config.go +++ b/markup/markup_config/config.go @@ -83,7 +83,6 @@ func applyLegacyConfig(cfg config.Provider, conf *Config) error { } return nil - } var Default = Config{ diff --git a/markup/markup_config/config_test.go b/markup/markup_config/config_test.go index fac4948d6..89da62bab 100644 --- a/markup/markup_config/config_test.go +++ b/markup/markup_config/config_test.go @@ -73,5 +73,4 @@ func TestConfig(t *testing.T) { c.Assert(conf.Highlight.CodeFences, qt.Equals, true) c.Assert(conf.Highlight.GuessSyntax, qt.Equals, true) }) - } diff --git a/markup/markup_test.go b/markup/markup_test.go index 314a941de..6e7fe2059 100644 --- a/markup/markup_test.go +++ b/markup/markup_test.go @@ -47,5 +47,4 @@ func TestConverterRegistry(t *testing.T) { checkName("pandoc") checkName("org") checkName("blackfriday") - } diff --git a/markup/mmark/convert.go b/markup/mmark/convert.go index 0682ad276..b4cc8b096 100644 --- a/markup/mmark/convert.go +++ b/markup/mmark/convert.go @@ -51,7 +51,6 @@ func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) cfg: cfg, }, nil }), nil - } type mmarkConverter struct { @@ -74,7 +73,6 @@ func getHTMLRenderer( ctx converter.DocumentContext, cfg blackfriday_config.Config, pcfg converter.ProviderConfig) mmark.Renderer { - var ( flags int documentID string @@ -99,7 +97,6 @@ func getHTMLRenderer( Config: pcfg, Renderer: mmark.HtmlRendererWithParameters(htmlFlags, "", "", renderParameters), } - } func getMmarkExtensions(cfg blackfriday_config.Config) int { diff --git a/markup/mmark/convert_test.go b/markup/mmark/convert_test.go index 3945f80da..01d3e8cbb 100644 --- a/markup/mmark/convert_test.go +++ b/markup/mmark/convert_test.go @@ -29,7 +29,7 @@ import ( func TestGetMmarkExtensions(t *testing.T) { b := blackfriday_config.Default - //TODO: This is doing the same just with different marks... + // TODO: This is doing the same just with different marks... type data struct { testFlag int } diff --git a/markup/pandoc/convert.go b/markup/pandoc/convert.go index 074e97d96..bbf619ce6 100644 --- a/markup/pandoc/convert.go +++ b/markup/pandoc/convert.go @@ -36,7 +36,6 @@ func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) cfg: cfg, }, nil }), nil - } type pandocConverter struct { diff --git a/markup/rst/convert.go b/markup/rst/convert.go index cbc15c81a..c397bf5fe 100644 --- a/markup/rst/convert.go +++ b/markup/rst/convert.go @@ -81,7 +81,7 @@ func (c *rstConverter) getRstContent(src []byte, ctx converter.DocumentContext) // TODO(bep) check if rst2html has a body only option. bodyStart := bytes.Index(result, []byte("\n")) if bodyStart < 0 { - bodyStart = -7 //compensate for length + bodyStart = -7 // compensate for length } bodyEnd := bytes.Index(result, []byte("\n")) diff --git a/markup/tableofcontents/tableofcontents.go b/markup/tableofcontents/tableofcontents.go index 9f1124233..b7e630d6f 100644 --- a/markup/tableofcontents/tableofcontents.go +++ b/markup/tableofcontents/tableofcontents.go @@ -131,8 +131,8 @@ func (b *tocBuilder) writeHeaders(level, indent int, h Headers) { b.s.WriteString("\n") b.indent(indent) } - } + func (b *tocBuilder) writeHeader(level, indent int, h Header) { b.indent(indent) b.s.WriteString("
  • ") diff --git a/markup/tableofcontents/tableofcontents_test.go b/markup/tableofcontents/tableofcontents_test.go index 8e5a47c52..753408ef9 100644 --- a/markup/tableofcontents/tableofcontents_test.go +++ b/markup/tableofcontents/tableofcontents_test.go @@ -152,5 +152,4 @@ func TestTocMissingParent(t *testing.T) {
  • `, qt.Commentf(got)) - } -- cgit v1.2.3