diff --git a/.github/workflows/test-dart-sass-v1.yml b/.github/workflows/test-dart-sass-v1.yml index d3556a647..fefb0e989 100644 --- a/.github/workflows/test-dart-sass-v1.yml +++ b/.github/workflows/test-dart-sass-v1.yml @@ -30,7 +30,7 @@ jobs: **/go.sum **/go.mod - name: Install Ruby - uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 + uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b with: ruby-version: '2.7' bundler-cache: true # diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c7dba1f91..3a76b768c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: **/go.sum **/go.mod - name: Install Ruby - uses: ruby/setup-ruby@ee2113536afb7f793eed4ce60e8d3b26db912da4 + uses: ruby/setup-ruby@036ef458ddccddb148a2b9fb67e95a22fdbf728b with: ruby-version: '2.7' bundler-cache: true # diff --git a/common/herrors/errors.go b/common/herrors/errors.go index 598c50b32..8e62b2c99 100644 --- a/common/herrors/errors.go +++ b/common/herrors/errors.go @@ -15,14 +15,12 @@ package herrors import ( - "bytes" "errors" "fmt" "io" "os" "runtime" "runtime/debug" - "strconv" ) // PrintStackTrace prints the current stacktrace to w. @@ -49,16 +47,6 @@ func Recover(args ...any) { } } -// GetGID the current goroutine id. Used only for debugging. -func GetGID() uint64 { - b := make([]byte, 64) - b = b[:runtime.Stack(b, false)] - b = bytes.TrimPrefix(b, []byte("goroutine ")) - b = b[:bytes.IndexByte(b, ' ')] - n, _ := strconv.ParseUint(string(b), 10, 64) - return n -} - // IsFeatureNotAvailableError returns true if the given error is or contains a FeatureNotAvailableError. func IsFeatureNotAvailableError(err error) bool { return errors.Is(err, &FeatureNotAvailableError{}) diff --git a/config/configProvider.go b/config/configProvider.go index 8e2ab0334..11099e407 100644 --- a/config/configProvider.go +++ b/config/configProvider.go @@ -95,9 +95,3 @@ func GetStringSlicePreserveString(cfg Provider, key string) []string { sd := cfg.Get(key) return types.ToStringSlicePreserveString(sd) } - -func setIfNotSet(cfg Provider, key string, value any) { - if !cfg.IsSet(key) { - cfg.Set(key, value) - } -} diff --git a/helpers/content.go b/helpers/content.go index c0a6d8221..a3abb334d 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -266,24 +266,3 @@ func (c *ContentSpec) TrimShortHTML(input []byte) []byte { func isEndOfSentence(r rune) bool { return r == '.' || r == '?' || r == '!' || r == '"' || r == '\n' } - -// Kept only for benchmark. -func (c *ContentSpec) truncateWordsToWholeSentenceOld(content string) (string, bool) { - words := strings.Fields(content) - - if c.Cfg.SummaryLength() >= len(words) { - return strings.Join(words, " "), false - } - - for counter, word := range words[c.Cfg.SummaryLength():] { - if strings.HasSuffix(word, ".") || - strings.HasSuffix(word, "?") || - strings.HasSuffix(word, ".\"") || - strings.HasSuffix(word, "!") { - upper := c.Cfg.SummaryLength() + counter + 1 - return strings.Join(words[:upper], " "), (upper < len(words)) - } - } - - return strings.Join(words[:c.Cfg.SummaryLength()], " "), true -} diff --git a/helpers/emoji.go b/helpers/emoji.go index a1617c48d..c103a5479 100644 --- a/helpers/emoji.go +++ b/helpers/emoji.go @@ -30,12 +30,6 @@ var ( emojiMaxSize int ) -// Emoji returns the emoji given a key, e.g. ":smile:", nil if not found. -func Emoji(key string) []byte { - emojiInit.Do(initEmoji) - return emojis[key] -} - // Emojify "emojifies" the input source. // Note that the input byte slice will be modified if needed. // See http://www.emoji-cheat-sheet.com/ diff --git a/helpers/general.go b/helpers/general.go index 281414b2a..b16aec0b0 100644 --- a/helpers/general.go +++ b/helpers/general.go @@ -32,7 +32,6 @@ import ( "github.com/jdkato/prose/transform" bp "github.com/gohugoio/hugo/bufferpool" - "github.com/spf13/pflag" ) // FilePathSeparator as defined by os.Separator. @@ -317,18 +316,6 @@ func IsWhitespace(r rune) bool { return r == ' ' || r == '\t' || r == '\n' || r == '\r' } -// NormalizeHugoFlags facilitates transitions of Hugo command-line flags, -// e.g. --baseUrl to --baseURL, --uglyUrls to --uglyURLs -func NormalizeHugoFlags(f *pflag.FlagSet, name string) pflag.NormalizedName { - switch name { - case "baseUrl": - name = "baseURL" - case "uglyUrls": - name = "uglyURLs" - } - return pflag.NormalizedName(name) -} - // PrintFs prints the given filesystem to the given writer starting from the given path. // This is useful for debugging. func PrintFs(fs afero.Fs, path string, w io.Writer) { diff --git a/htesting/testdata_builder.go b/htesting/testdata_builder.go deleted file mode 100644 index d7ba18521..000000000 --- a/htesting/testdata_builder.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2018 The Hugo Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package htesting - -import ( - "path/filepath" - "testing" - - "github.com/spf13/afero" -) - -type testFile struct { - name string - content string -} - -type testdataBuilder struct { - t testing.TB - fs afero.Fs - workingDir string - - files []testFile -} - -func NewTestdataBuilder(fs afero.Fs, workingDir string, t testing.TB) *testdataBuilder { - workingDir = filepath.Clean(workingDir) - return &testdataBuilder{fs: fs, workingDir: workingDir, t: t} -} - -func (b *testdataBuilder) Add(filename, content string) *testdataBuilder { - b.files = append(b.files, testFile{name: filename, content: content}) - return b -} - -func (b *testdataBuilder) Build() *testdataBuilder { - for _, f := range b.files { - if err := afero.WriteFile(b.fs, filepath.Join(b.workingDir, f.name), []byte(f.content), 0666); err != nil { - b.t.Fatalf("failed to add %q: %s", f.name, err) - } - } - return b -} - -func (b testdataBuilder) WithWorkingDir(dir string) *testdataBuilder { - b.workingDir = filepath.Clean(dir) - b.files = make([]testFile, 0) - return &b -} diff --git a/hugofs/fileinfo.go b/hugofs/fileinfo.go index c33997278..773352ea8 100644 --- a/hugofs/fileinfo.go +++ b/hugofs/fileinfo.go @@ -15,6 +15,7 @@ package hugofs import ( + "errors" "os" "path/filepath" "reflect" @@ -28,8 +29,6 @@ import ( "github.com/gohugoio/hugo/hugofs/files" "golang.org/x/text/unicode/norm" - "errors" - "github.com/gohugoio/hugo/common/hreflect" "github.com/gohugoio/hugo/common/htime" @@ -224,7 +223,8 @@ func newDirNameOnlyFileInfo(name string, meta *FileMeta, fileOpener func() (afer func decorateFileInfo( fi os.FileInfo, fs afero.Fs, opener func() (afero.File, error), - filename, filepath string, inMeta *FileMeta) FileMetaInfo { + filename, filepath string, inMeta *FileMeta, +) FileMetaInfo { var meta *FileMeta var fim FileMetaInfo @@ -289,13 +289,6 @@ func fileInfosToNames(fis []os.FileInfo) []string { return names } -func fromSlash(filenames []string) []string { - for i, name := range filenames { - filenames[i] = filepath.FromSlash(name) - } - return filenames -} - func sortFileInfos(fis []os.FileInfo) { sort.Slice(fis, func(i, j int) bool { fimi, fimj := fis[i].(FileMetaInfo), fis[j].(FileMetaInfo) diff --git a/hugofs/filename_filter_fs.go b/hugofs/filename_filter_fs.go index 4ecd1f55a..c101309c2 100644 --- a/hugofs/filename_filter_fs.go +++ b/hugofs/filename_filter_fs.go @@ -23,9 +23,7 @@ import ( "github.com/spf13/afero" ) -var ( - _ FilesystemUnwrapper = (*filenameFilterFs)(nil) -) +var _ FilesystemUnwrapper = (*filenameFilterFs)(nil) func newFilenameFilterFs(fs afero.Fs, base string, filter *glob.FilenameFilter) afero.Fs { return &filenameFilterFs{ @@ -93,12 +91,6 @@ func (fs *filenameFilterFs) Stat(name string) (os.FileInfo, error) { return fi, err } -func (fs *filenameFilterFs) getOpener(name string) func() (afero.File, error) { - return func() (afero.File, error) { - return fs.Open(name) - } -} - type filenameFilterDir struct { afero.File base string @@ -162,9 +154,11 @@ func (fs *filenameFilterFs) RemoveAll(p string) error { func (fs *filenameFilterFs) Rename(o, n string) error { return syscall.EPERM } + func (fs *filenameFilterFs) Create(n string) (afero.File, error) { return nil, syscall.EPERM } + func (fs *filenameFilterFs) Name() string { return "FinameFilterFS" } diff --git a/hugofs/fs.go b/hugofs/fs.go index 9462afa24..5b8a3adb2 100644 --- a/hugofs/fs.go +++ b/hugofs/fs.go @@ -60,14 +60,7 @@ type Fs struct { WorkingDirWritable afero.Fs } -// NewDefault creates a new Fs with the OS file system -// as source and destination file systems. -func NewDefault(conf config.BaseConfig) *Fs { - fs := Os - return NewFrom(fs, conf) -} - -func NewDefaultOld(cfg config.Provider) *Fs { +func NewDefault(cfg config.Provider) *Fs { workingDir, publishDir := getWorkingPublishDir(cfg) fs := Os return newFs(fs, fs, workingDir, publishDir) @@ -99,7 +92,6 @@ func getWorkingPublishDir(cfg config.Provider) (string, string) { publishDir = cfg.GetString("publishDir") } return workingDir, publishDir - } func newFs(source, destination afero.Fs, workingDir, publishDir string) *Fs { @@ -166,7 +158,7 @@ func MakeReadableAndRemoveAllModulePkgDir(fs afero.Fs, dir string) (int, error) } if info.IsDir() { counter++ - fs.Chmod(path, 0777) + fs.Chmod(path, 0o777) } return nil }) @@ -217,7 +209,6 @@ func WalkFilesystems(fs afero.Fs, fn WalkFn) bool { if WalkFilesystems(afs.UnwrapFilesystem(), fn) { return true } - } else if bfs, ok := fs.(FilesystemsUnwrapper); ok { for _, sf := range bfs.UnwrapFilesystems() { if WalkFilesystems(sf, fn) { diff --git a/hugofs/fs_test.go b/hugofs/fs_test.go index 509aca62f..b2ed2e86e 100644 --- a/hugofs/fs_test.go +++ b/hugofs/fs_test.go @@ -30,7 +30,6 @@ func TestIsOsFs(t *testing.T) { c.Assert(IsOsFs(&afero.MemMapFs{}), qt.Equals, false) c.Assert(IsOsFs(afero.NewBasePathFs(&afero.MemMapFs{}, "/public")), qt.Equals, false) c.Assert(IsOsFs(afero.NewBasePathFs(Os, t.TempDir())), qt.Equals, true) - } func TestNewDefault(t *testing.T) { @@ -38,7 +37,7 @@ func TestNewDefault(t *testing.T) { v := config.New() v.Set("workingDir", t.TempDir()) v.Set("publishDir", "public") - f := NewDefaultOld(v) + f := NewDefault(v) c.Assert(f.Source, qt.IsNotNil) c.Assert(f.Source, hqt.IsSameType, new(afero.OsFs)) diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index d5c94799d..a7c2a6271 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -57,7 +57,6 @@ var filePathSeparator = string(filepath.Separator) // to underline that even if they can be composites, they all have a base path set to a specific // resource folder, e.g "/my-project/content". So, no absolute filenames needed. type BaseFs struct { - // SourceFilesystems contains the different source file systems. *SourceFilesystems @@ -180,7 +179,6 @@ func (b *BaseFs) AbsProjectContentDir(filename string) (string, string, error) { return filename, filepath.Join(meta.Filename, filename), nil } } - } return "", "", fmt.Errorf("could not determine content directory for %q", filename) @@ -301,7 +299,6 @@ func (s SourceFilesystems) ContentStaticAssetFs(lang string) afero.Fs { }, }, ) - } // StaticFs returns the static filesystem for the given language. @@ -666,8 +663,8 @@ func (b *sourceFilesystemsBuilder) isStaticMount(mnt modules.Mount) bool { func (b *sourceFilesystemsBuilder) createOverlayFs( collector *filesystemsCollector, - mounts []mountsDescriptor) error { - + mounts []mountsDescriptor, +) error { if len(mounts) == 0 { appendNopIfEmpty := func(ofs *overlayfs.OverlayFs) *overlayfs.OverlayFs { if ofs.NumFilesystems() > 0 { @@ -857,13 +854,6 @@ func (c *filesystemsCollector) addDir(rfs *hugofs.RootMappingFs, componentFolder } } -func (c *filesystemsCollector) reverseFis(fis []hugofs.FileMetaInfo) { - for i := len(fis)/2 - 1; i >= 0; i-- { - opp := len(fis) - 1 - i - fis[i], fis[opp] = fis[opp], fis[i] - } -} - type mountsDescriptor struct { modules.Module dir string diff --git a/hugolib/hugo_modules_test.go b/hugolib/hugo_modules_test.go index 88a0c3ec6..44500cae5 100644 --- a/hugolib/hugo_modules_test.go +++ b/hugolib/hugo_modules_test.go @@ -63,11 +63,11 @@ path="github.com/gohugoio/hugoTestModule2" b := newTestSitesBuilder(t) tempDir := t.TempDir() workingDir := filepath.Join(tempDir, "myhugosite") - b.Assert(os.MkdirAll(workingDir, 0777), qt.IsNil) + b.Assert(os.MkdirAll(workingDir, 0o777), qt.IsNil) cfg := config.New() cfg.Set("workingDir", workingDir) cfg.Set("publishDir", "public") - b.Fs = hugofs.NewDefaultOld(cfg) + b.Fs = hugofs.NewDefault(cfg) b.WithWorkingDir(workingDir).WithConfigFile("toml", createConfig(workingDir, moduleOpts)) b.WithTemplates( "index.html", ` @@ -352,7 +352,7 @@ ignoreVendorPaths = %q b := newTestSitesBuilder(t) // Need to use OS fs for this. - b.Fs = hugofs.NewDefaultOld(v) + b.Fs = hugofs.NewDefault(v) b.WithWorkingDir(workingDir).WithConfigFile("toml", config) b.WithContent("page.md", ` @@ -683,11 +683,11 @@ Data: {{ .Site.Data }} createDirsAndFiles := func(baseDir string) { for _, dir := range files.ComponentFolders { realDir := filepath.Join(baseDir, dir, "real") - c.Assert(os.MkdirAll(realDir, 0777), qt.IsNil) - c.Assert(afero.WriteFile(fs.Source, filepath.Join(realDir, "data.toml"), []byte("[hello]\nother = \"hello\""), 0777), qt.IsNil) + c.Assert(os.MkdirAll(realDir, 0o777), qt.IsNil) + c.Assert(afero.WriteFile(fs.Source, filepath.Join(realDir, "data.toml"), []byte("[hello]\nother = \"hello\""), 0o777), qt.IsNil) } - c.Assert(afero.WriteFile(fs.Source, filepath.Join(baseDir, "layouts", "index.html"), []byte(homeTemplate), 0777), qt.IsNil) + c.Assert(afero.WriteFile(fs.Source, filepath.Join(baseDir, "layouts", "index.html"), []byte(homeTemplate), 0o777), qt.IsNil) } // Create project dirs and files. @@ -849,7 +849,7 @@ workingDir = %q cfg.Set("workingDir", workingDir) cfg.Set("publishDir", "public") - b.Fs = hugofs.NewDefaultOld(cfg) + b.Fs = hugofs.NewDefault(cfg) b.WithWorkingDir(workingDir).WithConfigFile("toml", tomlConfig) b.WithTemplatesAdded("index.html", ` @@ -877,8 +877,8 @@ workingDir = %q {{ .Text | safeHTML }} `) - os.Mkdir(filepath.Join(workingDir, "mycontent"), 0777) - os.Mkdir(filepath.Join(workingDir, "mycontent", "mybundle"), 0777) + os.Mkdir(filepath.Join(workingDir, "mycontent"), 0o777) + os.Mkdir(filepath.Join(workingDir, "mycontent", "mybundle"), 0o777) b.WithSourceFile("README.md", `--- title: "Readme Title" @@ -974,9 +974,9 @@ workingDir = %q cfg := config.New() cfg.Set("workingDir", workingDir) cfg.Set("publishDir", "public") - b.Fs = hugofs.NewDefaultOld(cfg) + b.Fs = hugofs.NewDefault(cfg) - os.MkdirAll(filepath.Join(workingDir, "content", "blog"), 0777) + os.MkdirAll(filepath.Join(workingDir, "content", "blog"), 0o777) b.WithWorkingDir(workingDir).WithConfigFile("toml", tomlConfig) @@ -1034,12 +1034,12 @@ title: P1 defer test.clean() subContentDir := filepath.Join(test.workingDir, "mycontent", "sub") - os.MkdirAll(subContentDir, 0777) + os.MkdirAll(subContentDir, 0o777) myPartialsDir := filepath.Join(test.workingDir, "subdir", "mypartials") - os.MkdirAll(myPartialsDir, 0777) + os.MkdirAll(myPartialsDir, 0o777) absShortcodesDir := filepath.Join(absDir, "abs", "myshortcodes") - os.MkdirAll(absShortcodesDir, 0777) + os.MkdirAll(absShortcodesDir, 0o777) b.WithSourceFile("README.md", "---\ntitle: Readme\n---") b.WithSourceFile("mycontent/sub/p1.md", "---\ntitle: P1\n---") @@ -1128,7 +1128,7 @@ title: Abs --- Content. -`), 0777) +`), 0o777) b.WithWorkingDir(workDir).WithConfigFile("toml", config) b.WithContent("dummy.md", "") diff --git a/hugolib/hugo_sites.go b/hugolib/hugo_sites.go index eb0385cda..f3f5c3eb2 100644 --- a/hugolib/hugo_sites.go +++ b/hugolib/hugo_sites.go @@ -50,7 +50,6 @@ import ( "github.com/gohugoio/hugo/resources/kinds" "github.com/gohugoio/hugo/resources/page" "github.com/gohugoio/hugo/resources/page/pagemeta" - "github.com/gohugoio/hugo/tpl" ) // HugoSites represents the sites to build. Each site represents a language. @@ -319,21 +318,6 @@ func (h *HugoSites) loadGitInfo() error { return nil } -func (s *Site) withSiteTemplates(withTemplates ...func(templ tpl.TemplateManager) error) func(templ tpl.TemplateManager) error { - return func(templ tpl.TemplateManager) error { - for _, wt := range withTemplates { - if wt == nil { - continue - } - if err := wt(templ); err != nil { - return err - } - } - - return nil - } -} - // Reset resets the sites and template caches etc., making it ready for a full rebuild. func (h *HugoSites) reset(config *BuildCfg) { if config.ResetState { @@ -659,7 +643,6 @@ func (h *HugoSites) errWithFileContext(err error, f source.File) error { realFilename := fim.Meta().Filename return herrors.NewFileErrorFromFile(err, realFilename, h.SourceSpec.Fs.Source, nil) - } func (h *HugoSites) readData(f source.File) (any, error) { diff --git a/hugolib/page.go b/hugolib/page.go index 2ea936af2..bf5e19ac4 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -851,10 +851,6 @@ func (p *pageState) pathOrTitle() string { return p.Title() } -func (p *pageState) posFromPage(offset int) text.Position { - return p.posFromInput(p.source.parsed.Input(), offset) -} - func (p *pageState) posFromInput(input []byte, offset int) text.Position { if offset < 0 { return text.Position{ diff --git a/hugolib/shortcode.go b/hugolib/shortcode.go index c10896bef..77c5b4e7e 100644 --- a/hugolib/shortcode.go +++ b/hugolib/shortcode.go @@ -484,10 +484,6 @@ func doRenderShortcode( return prerenderedShortcode{s: result, hasVariants: hasVariants}, err } -func (s *shortcodeHandler) hasShortcodes() bool { - return s != nil && len(s.shortcodes) > 0 -} - func (s *shortcodeHandler) addName(name string) { s.nameSetMu.Lock() defer s.nameSetMu.Unlock() @@ -529,13 +525,6 @@ func (s *shortcodeHandler) prepareShortcodesForPage(ctx context.Context, p *page return rendered, nil } -func (s *shortcodeHandler) parseError(err error, input []byte, pos int) error { - if s.p != nil { - return s.p.parseError(err, input, pos) - } - return err -} - // pageTokens state: // - before: positioned just before the shortcode start // - after: shortcode(s) consumed (plural when they are nested) diff --git a/hugolib/template_test.go b/hugolib/template_test.go index 802ce40e2..d18b4c6f0 100644 --- a/hugolib/template_test.go +++ b/hugolib/template_test.go @@ -16,7 +16,6 @@ package hugolib import ( "fmt" "path/filepath" - "strings" "testing" "github.com/gohugoio/hugo/config" @@ -636,10 +635,6 @@ func collectIdentities(set map[identity.Identity]bool, provider identity.Provide } } -func ident(level int) string { - return strings.Repeat(" ", level) -} - func TestPartialInline(t *testing.T) { b := newTestSitesBuilder(t) diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go index 700aa8c3d..cf054897d 100644 --- a/hugolib/testhelpers_test.go +++ b/hugolib/testhelpers_test.go @@ -43,7 +43,6 @@ import ( "github.com/spf13/cast" "github.com/gohugoio/hugo/helpers" - "github.com/gohugoio/hugo/tpl" "github.com/gohugoio/hugo/resources/resource" @@ -522,7 +521,7 @@ func (s *sitesBuilder) CreateSitesE() error { "data", "i18n", } { - if err := os.MkdirAll(filepath.Join(s.workingDir, dir), 0777); err != nil { + if err := os.MkdirAll(filepath.Join(s.workingDir, dir), 0o777); err != nil { return fmt.Errorf("failed to create %q: %w", dir, err) } } @@ -555,7 +554,6 @@ func (s *sitesBuilder) CreateSitesE() error { depsCfg.TestLogger = s.logger sites, err := NewHugoSites(depsCfg) - if err != nil { return fmt.Errorf("failed to create sites: %w", err) } @@ -878,20 +876,6 @@ func (th testHelper) assertFileContent(filename string, matches ...string) { } } -func (th testHelper) assertFileContentRegexp(filename string, matches ...string) { - filename = th.replaceDefaultContentLanguageValue(filename) - content := readWorkingDir(th, th.Fs, filename) - for _, match := range matches { - match = th.replaceDefaultContentLanguageValue(match) - r := regexp.MustCompile(match) - matches := r.MatchString(content) - if !matches { - fmt.Println("Expected to match regexp:\n"+match+"\nGot:\n", content) - } - th.Assert(matches, qt.Equals, true) - } -} - func (th testHelper) assertFileNotExist(filename string) { exists, err := helpers.Exists(filename, th.Fs.PublishDir) th.Assert(err, qt.IsNil) @@ -908,16 +892,11 @@ func (th testHelper) replaceDefaultContentLanguageValue(value string) string { return value } -func loadTestConfig(fs afero.Fs) (*allconfig.Configs, error) { - res, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{Fs: fs}) - return res, err -} - func loadTestConfigFromProvider(cfg config.Provider) (*allconfig.Configs, error) { workingDir := cfg.GetString("workingDir") fs := afero.NewMemMapFs() if workingDir != "" { - fs.MkdirAll(workingDir, 0755) + fs.MkdirAll(workingDir, 0o755) } res, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{Flags: cfg, Fs: fs}) return res, err @@ -972,18 +951,6 @@ func newTestSitesFromConfig(t testing.TB, afs afero.Fs, tomlConfig string, layou return th, h } -func createWithTemplateFromNameValues(additionalTemplates ...string) func(templ tpl.TemplateManager) error { - return func(templ tpl.TemplateManager) error { - for i := 0; i < len(additionalTemplates); i += 2 { - err := templ.AddTemplate(additionalTemplates[i], additionalTemplates[i+1]) - if err != nil { - return err - } - } - return nil - } -} - // TODO(bep) replace these with the builder func buildSingleSite(t testing.TB, depsCfg deps.DepsCfg, buildCfg BuildCfg) *Site { t.Helper() diff --git a/livereload/livereload.go b/livereload/livereload.go index 59d4c1286..f24b42f37 100644 --- a/livereload/livereload.go +++ b/livereload/livereload.go @@ -113,12 +113,6 @@ func ForceRefresh() { RefreshPath("/x.js") } -// NavigateToPath tells livereload to navigate to the given path. -// This translates to `window.location.href = path` in the client. -func NavigateToPath(path string) { - RefreshPath(hugoNavigatePrefix + path) -} - // NavigateToPathForPort is similar to NavigateToPath but will also // set window.location.port to the given port value. func NavigateToPathForPort(path string, port int) { diff --git a/markup/goldmark/links/transform.go b/markup/goldmark/links/transform.go index b4f6b6dc5..2a7815b70 100644 --- a/markup/goldmark/links/transform.go +++ b/markup/goldmark/links/transform.go @@ -1,11 +1,9 @@ package images import ( - "github.com/yuin/goldmark" "github.com/yuin/goldmark/ast" "github.com/yuin/goldmark/parser" "github.com/yuin/goldmark/text" - "github.com/yuin/goldmark/util" ) type ( @@ -20,18 +18,6 @@ const ( AttrIsBlock = "_h__isBlock" ) -func New(wrapStandAloneImageWithinParagraph bool) goldmark.Extender { - return &linksExtension{wrapStandAloneImageWithinParagraph: wrapStandAloneImageWithinParagraph} -} - -func (e *linksExtension) Extend(m goldmark.Markdown) { - m.Parser().AddOptions( - parser.WithASTTransformers( - util.Prioritized(&Transformer{wrapStandAloneImageWithinParagraph: e.wrapStandAloneImageWithinParagraph}, 300), - ), - ) -} - type Transformer struct { wrapStandAloneImageWithinParagraph bool } @@ -67,7 +53,5 @@ func (t *Transformer) Transform(doc *ast.Document, reader text.Reader, pctx pars } return ast.WalkContinue, nil - }) - } diff --git a/markup/highlight/highlight.go b/markup/highlight/highlight.go index c70659a09..85ea74124 100644 --- a/markup/highlight/highlight.go +++ b/markup/highlight/highlight.go @@ -232,7 +232,6 @@ func highlight(fw hugio.FlexiWriter, code, lang string, attributes []attributes. return `` }, } - } else { wrapper = getPreWrapper(lang, w) } @@ -314,10 +313,6 @@ func (s startEnd) End(code bool) string { return s.end(code) } -func WritePreEnd(w io.Writer) { - fmt.Fprint(w, preEnd) -} - func writeDivStart(w hugio.FlexiWriter, attrs []attributes.Attribute) { w.WriteString(`