# allow user to override go executable by running as GOEXE=xxx make ...
GOEXE="${GOEXE-go}"
-# Send in a regexp mathing the benchmarks you want to run, i.e. './benchSite.sh "YAML"'.
+# Send in a regexp matching the benchmarks you want to run, i.e. './benchSite.sh "YAML"'.
# Note the quotes, which will be needed for more complex expressions.
# The above will run all variations, but only for front matter YAML.
return info, b, nil
}
-// GetBytes gets the file content with the given id from the cahce, nil if none found.
+// GetBytes gets the file content with the given id from the cache, nil if none found.
func (c *Cache) GetBytes(id string) (ItemInfo, []byte, error) {
id = cleanID(id)
// GetOrCreate tries to get the value with the given cache key, if not found
// create will be called and cached.
// This method is thread safe. It also guarantees that the create func for a given
-// key is invoced only once for this cache.
+// key is invoked only once for this cache.
func (c *Cache) GetOrCreate(key string, create func() (interface{}, error)) (interface{}, error) {
c.mu.RLock()
entry, found := c.cache[key]
}
// ToMarshalJSON creates a MarshalJSON method for these methods. Any method name
-// matchin any of the regexps in excludes will be ignored.
+// matching any of the regexps in excludes will be ignored.
func (m Methods) ToMarshalJSON(receiver, pkgPath string, excludes ...string) (string, []string) {
var sb strings.Builder
}
// ReadSeekerNoOpCloser implements ReadSeekCloser by doing nothing in Close.
-// TODO(bep) rename this and simila to ReadSeekerNopCloser, naming used in stdlib, which kind of makes sense.
+// TODO(bep) rename this and similar to ReadSeekerNopCloser, naming used in stdlib, which kind of makes sense.
type ReadSeekerNoOpCloser struct {
ReadSeeker
}
WriteStats: false,
}
-// Build holds some build related condfiguration.
+// Build holds some build related configuration.
type Build struct {
UseResourceCacheWhen string // never, fallback, always. Default is fallback
// UnicodeSanitize sanitizes string to be used in Hugo URL's, allowing only
// a predefined set of special Unicode characters.
-// If RemovePathAccents configuration flag is enabled, Uniccode accents
+// If RemovePathAccents configuration flag is enabled, Unicode accents
// are also removed.
// Spaces will be replaced with a single hyphen, and sequential hyphens will be reduced to one.
func (p *PathSpec) UnicodeSanitize(s string) string {
return dottedPath
}
-// ExtNoDelimiter takes a path and returns the extension, excluding the delmiter, i.e. "md".
+// ExtNoDelimiter takes a path and returns the extension, excluding the delimiter, i.e. "md".
func ExtNoDelimiter(in string) string {
return strings.TrimPrefix(Ext(in), ".")
}
-// Ext takes a path and returns the extension, including the delmiter, i.e. ".md".
+// Ext takes a path and returns the extension, including the delimiter, i.e. ".md".
func Ext(in string) string {
_, ext := fileAndExt(in, fpb)
return ext
}
// FileAndExt takes a path and returns the file and extension separated,
-// the extension including the delmiter, i.e. ".md".
+// the extension including the delimiter, i.e. ".md".
func FileAndExt(in string) (string, string) {
return fileAndExt(in, fpb)
}
// FileAndExtNoDelimiter takes a path and returns the file and extension separated,
-// the extension excluding the delmiter, e.g "md".
+// the extension excluding the delimiter, e.g "md".
func FileAndExtNoDelimiter(in string) (string, string) {
file, ext := fileAndExt(in, fpb)
return file, strings.TrimPrefix(ext, ".")
Cfg config.Provider
}
-// NewPathSpec creats a new PathSpec from the given filesystems and language.
+// NewPathSpec creates a new PathSpec from the given filesystems and language.
func NewPathSpec(fs *hugofs.Fs, cfg config.Provider, logger loggers.Logger) (*PathSpec, error) {
return NewPathSpecWithBaseBaseFsProvided(fs, cfg, logger, nil)
}
return p.URLEscape(p.MakePathSanitized(uri))
}
-// URLizeFilename creates an URL from a filename by esacaping unicode letters
+// URLizeFilename creates an URL from a filename by escaping unicode letters
// and turn any filepath separator into forward slashes.
func (p *PathSpec) URLizeFilename(filename string) string {
return p.URLEscape(filepath.ToSlash(filename))
newPath := path.Join(url.Path, relativePath)
- // path strips traling slash, ignore root path.
+ // path strips trailing slash, ignore root path.
if newPath != "/" && strings.HasSuffix(relativePath, "/") {
newPath += "/"
}
}
// Try to extract the language from the given filename.
-// Any valid language identificator in the name will win over the
+// Any valid language identifier in the name will win over the
// language set on the file system, e.g. "mypost.en.md".
func langInfoFrom(languages map[string]int, name string) (string, string, string) {
var lang string
// Check readdir
f, err = fs.Open(workDir)
c.Assert(err, qt.IsNil)
- // There is at least one unsported symlink inside workDir
+ // There is at least one unsupported symlink inside workDir
_, err = f.Readdir(-1)
c.Assert(err, qt.IsNil)
f.Close()
c.Assert(err, qt.IsNil)
c.Assert(string(b), qt.Equals, "some no content")
- // Ambigous
+ // Ambiguous
_, err = rfs.Stat(filepath.FromSlash("content/singles/p1.md"))
c.Assert(err, qt.Not(qt.IsNil))
)
func Test073(t *testing.T) {
- asertDisabledTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) {
+ assertDisabledTaxonomyAndTerm := func(b *sitesBuilder, taxonomy, term bool) {
b.Assert(b.CheckExists("public/tags/index.html"), qt.Equals, taxonomy)
b.Assert(b.CheckExists("public/tags/tag1/index.html"), qt.Equals, term)
}
`disableKinds = ["taxonomy", "taxonomyTerm"]`,
func(err error, out string, b *sitesBuilder) {
b.Assert(err, qt.IsNil)
- asertDisabledTaxonomyAndTerm(b, false, false)
+ assertDisabledTaxonomyAndTerm(b, false, false)
},
},
{
`disableKinds = ["taxonomyTerm"]`,
func(err error, out string, b *sitesBuilder) {
b.Assert(err, qt.IsNil)
- asertDisabledTaxonomyAndTerm(b, false, true)
+ assertDisabledTaxonomyAndTerm(b, false, true)
},
},
{
ignoreErrors = ["error-disable-taxonomy"]`,
func(err error, out string, b *sitesBuilder) {
b.Assert(err, qt.IsNil)
- asertDisabledTaxonomyAndTerm(b, false, true)
+ assertDisabledTaxonomyAndTerm(b, false, true)
},
},
} {
cmLeafSeparator = "__hl_"
)
-// Used to mark ambigous keys in reverse index lookups.
-var ambigousContentNode = &contentNode{}
+// Used to mark ambiguous keys in reverse index lookups.
+var ambiguousContentNode = &contentNode{}
func newContentMap(cfg contentMapConfig) *contentMap {
m := &contentMap{
addToReverseMap := func(k string, n *contentNode, m map[interface{}]*contentNode) {
k = strings.ToLower(k)
existing, found := m[k]
- if found && existing != ambigousContentNode {
- m[k] = ambigousContentNode
+ if found && existing != ambiguousContentNode {
+ m[k] = ambiguousContentNode
} else if !found {
m[k] = n
}
outputFormats := owner.m.outputFormats()
seen := make(map[string]bool)
var targetBasePaths []string
- // Make sure bundled resources are published to all of the ouptput formats'
+ // Make sure bundled resources are published to all of the output formats'
// sub paths.
for _, f := range outputFormats {
p := f.Path
`{{< youtube id="w7Ft2ymGmfc" class="video" autoplay="true" >}}`,
"(?s)\n<div class=\"video\">.*?<iframe src=\"https://www.youtube.com/embed/w7Ft2ymGmfc\\?autoplay=1\".*?allowfullscreen title=\"YouTube Video\">.*?</iframe>.*?</div>",
},
- // set custom title for accessability)
+ // set custom title for accessibility)
{
`{{< youtube id="w7Ft2ymGmfc" title="A New Hugo Site in Under Two Minutes" >}}`,
"(?s)\n<div style=\".*?\">.*?<iframe src=\"https://www.youtube.com/embed/w7Ft2ymGmfc\" style=\".*?\" allowfullscreen title=\"A New Hugo Site in Under Two Minutes\">.*?</iframe>.*?</div>",
"devDependencies": {
"postcss-cli": "7.8.0",
"tailwindcss": "1.8.0"
-
+
}
}`)
}
func createChildModMatchers(m *mods.Md, ignoreVendor, vendored bool) []string {
- // Child depdendencies are one behind.
+ // Child dependencies are one behind.
expectMinorVersion := 3
if !ignoreVendor && vendored {
[[module.mounts]]
source = %q
target = "content"
-
+
`, workDir, absContentDir)
defer clean1()
Markup string
}
-var defualtRenderStringOpts = renderStringOpts{
+var defaultRenderStringOpts = renderStringOpts{
Display: "inline",
Markup: "", // Will inherit the page's value when not set.
}
}
var s string
- opts := defualtRenderStringOpts
+ opts := defaultRenderStringOpts
sidx := 1
if len(args) == 1 {
//
// For pages that have a source file, it is returns the path to this file as an
// absolute path rooted in this site's content dir.
-// For pages that do not (sections witout content page etc.), it returns the
+// For pages that do not (sections without content page etc.), it returns the
// virtual path, consistent with where you would add a source file.
func (p *pageState) sourceRef() string {
if !p.File().IsZero() {
bucket *pagesMapBucket
treeRef *contentTreeRef
- // Laziliy initialized dependencies.
+ // Lazily initialized dependencies.
init *lazy.Init
// All of these represents the common parts of a page.Page
// A bundle in a/b/index.en.md
// a/b/index.en.md => OK
// a/b/index => OK
- // index.en.md => ambigous, but OK.
+ // index.en.md => ambiguous, but OK.
// With bundles, the file name has little meaning, the folder it lives in does. So this should also work:
// a/b
// and probably also just b (aka "my-bundle")
title: "Page"
weight: %d
---
-
+
`, i))
b.WithSourceFile(fmt.Sprintf("content/bundle%d/data.yaml", i), fmt.Sprintf(`data: v%d`, i))
b.WithSourceFile(fmt.Sprintf("content/bundle%d/data.json", i), fmt.Sprintf(`{ "data": "v%d" }`, i))
// This is an adapter func for the old API with Kind as first argument.
// This is invoked when you do .Site.GetPage. We drop the Kind and fails
-// if there are more than 2 arguments, which would be ambigous.
+// if there are more than 2 arguments, which would be ambiguous.
func (c *PageCollections) getPageOldVersion(ref ...string) (page.Page, error) {
var refs []string
for _, r := range ref {
getByName := func(s string) (*contentNode, error) {
n := m.pageReverseIndex.Get(s)
if n != nil {
- if n == ambigousContentNode {
+ if n == ambiguousContentNode {
return nil, fmt.Errorf("page reference %q is ambiguous", ref)
}
return n, nil
if btyp == bundleBranch {
// No special logic for branch bundles.
// Every language needs its own _index.md file.
- // Also, we only clone bundle headers for lonsesome, bundled,
+ // Also, we only clone bundle headers for lonesome, bundled,
// content files.
return c.handleFiles(info)
}
return strings.TrimPrefix(strings.TrimPrefix(filename, p.WorkingDir), FilePathSeparator)
}
-// AbsPathify creates an absolute path if given a working dir and arelative path.
+// AbsPathify creates an absolute path if given a working dir and a relative path.
// If already absolute, the path is just cleaned.
func AbsPathify(workingDir, inPath string) string {
if filepath.IsAbs(inPath) {
eventMap := make(map[string][]fsnotify.Event)
// We often get a Remove etc. followed by a Create, a Create followed by a Write.
- // Remove the superflous events to mage the update logic simpler.
+ // Remove the superfluous events to mage the update logic simpler.
for _, ev := range events {
eventMap[ev.Name] = append(eventMap[ev.Name], ev)
}
)
// reBuild partially rebuilds a site given the filesystem events.
-// It returns whetever the content source was changed.
+// It returns whatever the content source was changed.
// TODO(bep) clean up/rewrite this method.
func (s *Site) processPartial(config *BuildCfg, init func(config *BuildCfg) error, events []fsnotify.Event) error {
events = s.filterFileEvents(events)
}
}
-// get any lanaguagecode to prefix the target file path with.
+// get any language code to prefix the target file path with.
func (s *Site) getLanguageTargetPathLang(alwaysInSubDir bool) string {
if s.h.IsMultihost() {
return s.Language().Lang
---
Content.
-
+
`)
}
`,
"categories/_index.md", "---\ntitle: Categories Page\n---",
"categories/data.json", "Category data",
- "categories/funny/_index.md", "---\ntitle: Funnny Category\n---",
+ "categories/funny/_index.md", "---\ntitle: Funny Category\n---",
"categories/funny/funnydata.json", "Category funny data",
)
func TestTaxonomiesListPages(t *testing.T) {
b := newTestSitesBuilder(t)
b.WithTemplates("_default/list.html", `
-
+
{{ template "print-taxo" "categories.cats" }}
{{ template "print-taxo" "categories.funny" }}
b.Build(BuildCfg{})
b.AssertFileContent("public/index.html", `
-
+
Len categories.cats: 2
categories.cats:|/blog/|
categories.cats:|/|
return buildSingleSiteExpected(t, false, false, depsCfg, buildCfg)
}
-func buildSingleSiteExpected(t testing.TB, expectSiteInitEror, expectBuildError bool, depsCfg deps.DepsCfg, buildCfg BuildCfg) *Site {
+func buildSingleSiteExpected(t testing.TB, expectSiteInitError, expectBuildError bool, depsCfg deps.DepsCfg, buildCfg BuildCfg) *Site {
t.Helper()
b := newTestSitesBuilderFromDepsCfg(t, depsCfg).WithNothingAdded()
err := b.CreateSitesE()
- if expectSiteInitEror {
+ if expectSiteInitError {
b.Assert(err, qt.Not(qt.IsNil))
return nil
} else {
func (l Languages) Swap(i, j int) { l[i], l[j] = l[j], l[i] }
-// Params retunrs language-specific params merged with the global params.
+// Params returns language-specific params merged with the global params.
func (l *Language) Params() maps.Params {
// TODO(bep) this construct should not be needed. Create the
// language params in one go.
return opts, nil
}
-// startLine compansates for https://github.com/alecthomas/chroma/issues/30
+// startLine compensates for https://github.com/alecthomas/chroma/issues/30
func hlLinesToRanges(startLine int, s string) ([][2]int, error) {
var ranges [][2]int
s = strings.TrimSpace(s)
SubType string `json:"subType"` // i.e. html
// This is the optional suffix after the "+" in the MIME type,
- // e.g. "xml" in "applicatiion/rss+xml".
+ // e.g. "xml" in "application/rss+xml".
mimeSuffix string
Delimiter string `json:"delimiter"` // e.g. "."
return m.Delimiter + m.Suffix()
}
-// Suffix returns the file suffix without any delmiter prepended.
+// Suffix returns the file suffix without any delimiter prepended.
func (m Type) Suffix() string {
if m.fileSuffix != "" {
return m.fileSuffix
}{
{media.HTMLType, "<hello> Hugo! </hello>", "<hello> Hugo! </hello>", false}, // configured minifier
{media.CSSType, " body { color: blue; } ", "body{color:blue}", false}, // default minifier
- {media.XMLType, " <hello> Hugo! </hello> ", "", true}, // disable Xml minificatin
+ {media.XMLType, " <hello> Hugo! </hello> ", "", true}, // disable Xml minification
} {
var b bytes.Buffer
if !test.errorExpected {
for _, m := range mounts {
if strings.HasPrefix(m.Target, files.JsConfigFolderMountPrefix) {
// This follows the convention of the other component types (assets, content, etc.),
- // if one or more is specificed by the user, we skip the defaults.
+ // if one or more is specified by the user, we skip the defaults.
// These mounts were added to Hugo in 0.75.
return mounts, nil
}
case float64:
return cast.ToFloat64E(data)
default:
- return nil, errors.Errorf("unmarshal: %T not supportedd", typ)
+ return nil, errors.Errorf("unmarshal: %T not supported", typ)
}
}
}
if l.isInHTMLComment {
- return lexEndFromtMatterHTMLComment
+ return lexEndFrontMatterHTMLComment
}
// Fast forward as far as possible.
return lexMainSection
}
-func lexEndFromtMatterHTMLComment(l *pageLexer) stateFunc {
+func lexEndFrontMatterHTMLComment(l *pageLexer) stateFunc {
l.isInHTMLComment = false
right := l.index(htmlCommentEnd)
if right == -1 {
l.backup()
break Loop
} else if openQuoteFound {
- // the coming quoute is inside
+ // the coming quote is inside
escapedInnerQuoteFound = true
escapedQuoteState = 1
}
}
}
-// Consume is a convencience method to consume the next n tokens,
+// Consume is a convenience method to consume the next n tokens,
// but back off Errors and EOF.
func (t *Iterator) Consume(cnt int) {
for i := 0; i < cnt; i++ {
return
}
-// The net/html parser does not handle single table elemnts as input, e.g. tbody.
+// The net/html parser does not handle single table elements as input, e.g. tbody.
// We only care about the element/class/ids, so just store away the original tag name
// and pretend it's a <div>.
func (c *cssClassCollectorWriter) insertStandinHTMLElement(el string) (string, string) {
return err
}
- prepareRelaseNotes := isPatch || relNotesState == releaseNotesNone
+ prepareReleaseNotes := isPatch || relNotesState == releaseNotesNone
shouldRelease := isPatch || relNotesState == releaseNotesReady
defer r.gitPush() // TODO(bep)
- if prepareRelaseNotes || shouldRelease {
+ if prepareReleaseNotes || shouldRelease {
gitCommits, err = getGitInfos(changeLogFromTag, "hugo", "", !r.try)
if err != nil {
return err
}
if relNotesState == releaseNotesCreated {
- fmt.Println("Release notes created, but not ready. Reneame to *-ready.md to continue ...")
+ fmt.Println("Release notes created, but not ready. Rename to *-ready.md to continue ...")
return nil
}
- if prepareRelaseNotes {
+ if prepareReleaseNotes {
releaseNotesFile, err := r.writeReleaseNotesToTemp(version, isPatch, gitCommits, gitCommitsDocs)
if err != nil {
return err
var img *images.Image
- if u.isContenChanged() {
+ if u.isContentChanged() {
img = i.WithSpec(base)
} else {
img = i.Image
}
}
-// The cache key is a lowecase path with Unix style slashes and it always starts with
+// The cache key is a lowercase path with Unix style slashes and it always starts with
// a leading slash.
func (c *imageCache) normalizeKey(key string) string {
return "/" + c.normalizeKeyBase(key)
assertImageFile(c, spec.BaseFs.PublishFs, publishedImageFilename, 101, 101)
c.Assert(spec.BaseFs.PublishFs.Remove(publishedImageFilename), qt.IsNil)
- // Cleare mem cache to simulate reading from the file cache.
+ // Clear mem cache to simulate reading from the file cache.
spec.imageCache.clear()
resizedAgain, err := image.Resize("101x101")
// Exclude these methods
excludes := []reflect.Type{
- // We need to eveluate the deprecated vs JSON in the future,
+ // We need to evaluate the deprecated vs JSON in the future,
// but leave them out for now.
pageInterfaceDeprecated,
"Hugo": "Use the global hugo function.",
"LanguagePrefix": "Use .Site.LanguagePrefix.",
"GetParam": "Use .Param or .Params.myParam.",
- "RSSLink": `Use the Output Format's link, e.g. something like:
+ "RSSLink": `Use the Output Format's link, e.g. something like:
{{ with .OutputFormats.Get "RSS" }}{{ .RelPermalink }}{{ end }}`,
"URL": "Use .Permalink or .RelPermalink. If what you want is the front matter URL value, use .Params.url",
}
%s
// ZeroFile represents a zero value of source.File with warnings if invoked.
-type zeroFile struct {
- log *helpers.DistinctLogger
+type zeroFile struct {
+ log *helpers.DistinctLogger
}
func NewZeroFile(log *helpers.DistinctLogger) source.File {
// OutputFormat links to a representation of a resource.
type OutputFormat struct {
- // Rel constains a value that can be used to construct a rel link.
+ // Rel contains a value that can be used to construct a rel link.
// This is value is fetched from the output format definition.
// Note that for pages with only one output format,
// this method will always return "canonical".
return p.groupByDateField(sorter, formatter, order...)
}
-// ProbablyEq wraps comare.ProbablyEqer
+// ProbablyEq wraps compare.ProbablyEqer
func (p PageGroup) ProbablyEq(other interface{}) bool {
otherP, ok := other.(PageGroup)
if !ok {
return l
}
-// ProbablyEq wraps comare.ProbablyEqer
+// ProbablyEq wraps compare.ProbablyEqer
func (psg PagesGroup) ProbablyEq(other interface{}) bool {
otherPsg, ok := other.(PagesGroup)
if !ok {
return len(p)
}
-// ProbablyEq wraps comare.ProbablyEqer
+// ProbablyEq wraps compare.ProbablyEqer
func (pages Pages) ProbablyEq(other interface{}) bool {
otherPages, ok := other.(Pages)
if !ok {
package page
-// Next returns the next page reletive to the given
+// Next returns the next page relative to the given
func (p Pages) Next(cur Page) Page {
x := searchPage(cur, p)
if x <= 0 {
d, ok := p[0].(InternalDependencies)
if !ok {
- return nil, errors.Errorf("invalid type %T in related serch", p[0])
+ return nil, errors.Errorf("invalid type %T in related search", p[0])
}
cache := d.GetRelatedDocsHandler()
// Fast path:
// This is a processed version of the original;
- // check if it already existis at the destination.
+ // check if it already exists at the destination.
for _, targetFilename := range targetFilenames {
if _, err := l.getSpec().BaseFs.PublishFs.Stat(targetFilename); err == nil {
continue
targetPathBuilder func() page.TargetPaths
// This will normally be the same as above, but this will only apply to publishing
- // of resources. It may be mulltiple values when in multihost mode.
+ // of resources. It may be multiple values when in multihost mode.
baseTargetPathDirs []string
// baseOffset is set when the output format's path has a offset, e.g. for AMP.
ext := strings.ToLower(filepath.Ext(fd.RelTargetFilename))
mimeType, found := r.MediaTypes.GetFirstBySuffix(strings.TrimPrefix(ext, "."))
- // TODO(bep) we need to handle these ambigous types better, but in this context
+ // TODO(bep) we need to handle these ambiguous types better, but in this context
// we most likely want the application/xml type.
if mimeType.Suffix() == "xml" && mimeType.SubType == "rss" {
mimeType, found = r.MediaTypes.GetByType("application/xml")
c.Assert(r.ResourceType(), qt.Equals, "css")
}
-func TestGenericResourceWithLinkFacory(t *testing.T) {
+func TestGenericResourceWithLinkFactory(t *testing.T) {
c := qt.New(t)
spec := newTestResourceSpec(specDescriptor{c: c})
configFile = filepath.Clean(configFile)
- // We need an abolute filename to the config file.
+ // We need an absolute filename to the config file.
if !filepath.IsAbs(configFile) {
configFile = t.rs.BaseFs.ResolveJSConfigFile(configFile)
if configFile == "" && t.options.Config != "" {
- // Only fail if the user specificed config file is not found.
+ // Only fail if the user specified config file is not found.
return errors.Errorf("babel config %q not found:", configFile)
}
}
"github.com/gohugoio/hugo/resources/resource"
)
-// Client for minification of Resource objects. Supported minfiers are:
+// Client for minification of Resource objects. Supported minifiers are:
// css, html, js, json, svg and xml.
type Client struct {
rs *resources.Spec
configFile = filepath.Clean(configFile)
- // We need an abolute filename to the config file.
+ // We need an absolute filename to the config file.
if !filepath.IsAbs(configFile) {
configFile = t.rs.BaseFs.ResolveJSConfigFile(configFile)
if configFile == "" && t.options.Config != "" {
- // Only fail if the user specificed config file is not found.
+ // Only fail if the user specified config file is not found.
return errors.Errorf("postcss config %q not found:", configFile)
}
}
// to be simple types, as it needs to be serialized to JSON and back.
Data map[string]interface{}
- // This is used to publis additional artifacts, e.g. source maps.
+ // This is used to publish additional artifacts, e.g. source maps.
// We may improve this.
OpenResourcePublisher func(relTargetPath string) (io.WriteCloser, error)
}
publishwriters = append(publishwriters, metaw)
}
- // Any transofrmations reading from From must also write to To.
+ // Any transformations reading from From must also write to To.
// This means that if the target buffer is empty, we can just reuse
// the original reader.
if b, ok := tctx.To.(*bytes.Buffer); ok && b.Len() > 0 {
startCtx ResourceTransformationCtx
}
-func (u *transformationUpdate) isContenChanged() bool {
+func (u *transformationUpdate) isContentChanged() bool {
return u.content != nil || u.sourceFilename != nil
}
func (fi *FileInfo) BaseFileName() string { return fi.baseName }
// TranslationBaseName returns a file's translation base name without the
-// language segement (ie. "page").
+// language segment (ie. "page").
func (fi *FileInfo) TranslationBaseName() string { return fi.translationBaseName }
// ContentBaseName is a either TranslationBaseName or name of containing folder
baseName := helpers.Filename(name)
if translationBaseName == "" {
- // This is usyally provided by the filesystem. But this FileInfo is also
+ // This is usually provided by the filesystem. But this FileInfo is also
// created in a standalone context when doing "hugo new". This is
// an approximate implementation, which is "good enough" in that case.
fileLangExt := filepath.Ext(baseName)
// Note that this test can fail with false negative result if the shuffle
// of the sequence happens to be the same as the original sequence. However
- // the propability of the event is 10^-158 which is negligible.
+ // the probability of the event is 10^-158 which is negligible.
seqLen := 100
rand.Seed(time.Now().UTC().UnixNano())
// Structs
{pagesVals{p3v, p2v, p3v, p2v}, pagesVals{p3v, p2v}, false},
- // not Comparable(), use hashstruscture
+ // not Comparable(), use hashstructure
{[]map[string]int{
{"K1": 1}, {"K2": 2}, {"K1": 1}, {"K2": 1},
}, []map[string]int{
"github.com/pkg/errors"
)
-// Merge creates a copy of the final parameter and merges the preceeding
+// Merge creates a copy of the final parameter and merges the preceding
// parameters into it in reverse order.
// Currently only maps are supported. Key handling is case insensitive.
func (ns *Namespace) Merge(params ...interface{}) (interface{}, error) {
{[]int{1, 2, 3, 4, 5}, nil, "asc", []int{1, 2, 3, 4, 5}},
{[]int{5, 4, 3, 1, 2}, nil, "asc", []int{1, 2, 3, 4, 5}},
- // test sort key parameter is focibly set empty
+ // test sort key parameter is forcibly set empty
{[]string{"class3", "class1", "class2"}, map[int]string{1: "a"}, "asc", []string{"class1", "class2", "class3"}},
// test map sorting by keys
{map[string]int{"1": 10, "2": 20, "3": 30, "4": 40, "5": 50}, nil, "asc", []int{10, 20, 30, 40, 50}},
func (*Namespace) Default(dflt interface{}, given ...interface{}) (interface{}, error) {
// given is variadic because the following construct will not pass a piped
// argument when the key is missing: {{ index . "key" | default "foo" }}
- // The Go template will complain that we got 1 argument when we expectd 2.
+ // The Go template will complain that we got 1 argument when we expected 2.
if len(given) == 0 {
return dflt, nil
return
}
-// Below are modifed structs etc. The changes are marked with "Added for Hugo."
+// Below are modified structs etc. The changes are marked with "Added for Hugo."
// state represents the state of an execution. It's not part of the
// template so that multiple executions of the same template
// See the License for the specific language governing permissions and
// limitations under the License.
-// Package math provides template functions for mathmatical operations.
+// Package math provides template functions for mathematical operations.
package math
import (
deps *deps.Deps
}
-// CountRunes returns the number of runes in s, excluding whitepace.
+// CountRunes returns the number of runes in s, excluding whitespace.
func (ns *Namespace) CountRunes(s interface{}) (int, error) {
ss, err := cast.ToStringE(s)
if err != nil {
TemplateFinder
}
-// TemplateDebugger prints some debug info to stdoud.
+// TemplateDebugger prints some debug info to stdout.
type TemplateDebugger interface {
Debug()
}
func main() {
templateFolder := filepath.Join("..", "templates")
- temlatePath := filepath.Join(".", templateFolder)
+ templatePath := filepath.Join(".", templateFolder)
file, err := os.Create("../templates.autogen.go")
if err != nil {
var nameValues []string
- err = filepath.Walk(temlatePath, func(path string, info os.FileInfo, err error) error {
+ err = filepath.Walk(templatePath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
return m, nil
case []string:
if len(v) == 0 || len(v) > 2 {
- return nil, fmt.Errorf("invalid numer of arguments to ref")
+ return nil, fmt.Errorf("invalid number of arguments to ref")
}
// These where the options before we introduced the map type:
s = v[0]
}
}
-func TestChaingMultipleTransformers(t *testing.T) {
+func TestChainingMultipleTransformers(t *testing.T) {
f1 := func(ct FromTo) error {
_, err := ct.To().Write(bytes.Replace(ct.From().Bytes(), []byte("f1"), []byte("f1r"), -1))
return err
h5JsContentSingleQuote = "<!DOCTYPE html><html><head><script src='foobar.js'></script><script src='/barfoo.js'></script></head><body><nav><h1>title</h1></nav><article>content <a href='foobar'>foobar</a>. <a href='/foobar'>Follow up</a></article></body></html>"
h5JsContentAbsURL = "<!DOCTYPE html><html><head><script src=\"http://user@host:10234/foobar.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href=\"https://host/foobar\">foobar</a>. Follow up</article></body></html>"
h5JsContentAbsURLSchemaless = "<!DOCTYPE html><html><head><script src=\"//host/foobar.js\"></script><script src='//host2/barfoo.js'></head><body><nav><h1>title</h1></nav><article>content <a href=\"//host/foobar\">foobar</a>. <a href='//host2/foobar'>Follow up</a></article></body></html>"
- corectOutputSrcHrefDq = "<!DOCTYPE html><html><head><script src=\"foobar.js\"></script><script src=\"http://base/barfoo.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href=\"foobar\">foobar</a>. <a href=\"http://base/foobar\">Follow up</a></article></body></html>"
- corectOutputSrcHrefSq = "<!DOCTYPE html><html><head><script src='foobar.js'></script><script src='http://base/barfoo.js'></script></head><body><nav><h1>title</h1></nav><article>content <a href='foobar'>foobar</a>. <a href='http://base/foobar'>Follow up</a></article></body></html>"
+ correctOutputSrcHrefDq = "<!DOCTYPE html><html><head><script src=\"foobar.js\"></script><script src=\"http://base/barfoo.js\"></script></head><body><nav><h1>title</h1></nav><article>content <a href=\"foobar\">foobar</a>. <a href=\"http://base/foobar\">Follow up</a></article></body></html>"
+ correctOutputSrcHrefSq = "<!DOCTYPE html><html><head><script src='foobar.js'></script><script src='http://base/barfoo.js'></script></head><body><nav><h1>title</h1></nav><article>content <a href='foobar'>foobar</a>. <a href='http://base/foobar'>Follow up</a></article></body></html>"
- h5XMLXontentAbsURL = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?><feed xmlns=\"http://www.w3.org/2005/Atom\"><entry><content type=\"html\"><p><a href="/foobar">foobar</a></p> <p>A video: <iframe src='/foo'></iframe></p></content></entry></feed>"
+ h5XMLContentAbsURL = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?><feed xmlns=\"http://www.w3.org/2005/Atom\"><entry><content type=\"html\"><p><a href="/foobar">foobar</a></p> <p>A video: <iframe src='/foo'></iframe></p></content></entry></feed>"
correctOutputSrcHrefInXML = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?><feed xmlns=\"http://www.w3.org/2005/Atom\"><entry><content type=\"html\"><p><a href="http://base/foobar">foobar</a></p> <p>A video: <iframe src='http://base/foo'></iframe></p></content></entry></feed>"
h5XMLContentGuarded = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?><feed xmlns=\"http://www.w3.org/2005/Atom\"><entry><content type=\"html\"><p><a href="//foobar">foobar</a></p> <p>A video: <iframe src='//foo'></iframe></p></content></entry></feed>"
)
srcsetXMLBasicCorrect = `Pre. <img srcset="http://base/img/small.jpg 200w, http://base/img/big.jpg 700w" alt="text" src="http://base/img/foo.jpg">`
srcsetXMLSingleQuote = `Pre. <img srcset="/img/small.jpg 200w, /img/big.jpg 700w" alt="text" src="/img/foo.jpg">`
srcsetXMLSingleQuoteCorrect = `Pre. <img srcset="http://base/img/small.jpg 200w, http://base/img/big.jpg 700w" alt="text" src="http://base/img/foo.jpg">`
- srcsetVariations = `Pre.
-Missing start quote: <img srcset=/img/small.jpg 200w, /img/big.jpg 700w" alt="text"> src='/img/foo.jpg'> FOO.
-<img srcset='/img.jpg'>
+ srcsetVariations = `Pre.
+Missing start quote: <img srcset=/img/small.jpg 200w, /img/big.jpg 700w" alt="text"> src='/img/foo.jpg'> FOO.
+<img srcset='/img.jpg'>
schemaless: <img srcset='//img.jpg' src='//basic.jpg'>
schemaless2: <img srcset="//img.jpg" src="//basic.jpg2> POST
`
)
const (
- srcsetVariationsCorrect = `Pre.
-Missing start quote: <img srcset=/img/small.jpg 200w, /img/big.jpg 700w" alt="text"> src='http://base/img/foo.jpg'> FOO.
-<img srcset='http://base/img.jpg'>
+ srcsetVariationsCorrect = `Pre.
+Missing start quote: <img srcset=/img/small.jpg 200w, /img/big.jpg 700w" alt="text"> src='http://base/img/foo.jpg'> FOO.
+<img srcset='http://base/img.jpg'>
schemaless: <img srcset='//img.jpg' src='//basic.jpg'>
schemaless2: <img srcset="//img.jpg" src="//basic.jpg2> POST
`
- srcsetXMLVariations = `Pre.
-Missing start quote: <img srcset=/img/small.jpg 200w /img/big.jpg 700w" alt="text"> src='/img/foo.jpg'> FOO.
-<img srcset='/img.jpg'>
+ srcsetXMLVariations = `Pre.
+Missing start quote: <img srcset=/img/small.jpg 200w /img/big.jpg 700w" alt="text"> src='/img/foo.jpg'> FOO.
+<img srcset='/img.jpg'>
schemaless: <img srcset='//img.jpg' src='//basic.jpg'>
schemaless2: <img srcset="//img.jpg" src="//basic.jpg2> POST
`
- srcsetXMLVariationsCorrect = `Pre.
-Missing start quote: <img srcset=/img/small.jpg 200w /img/big.jpg 700w" alt="text"> src='http://base/img/foo.jpg'> FOO.
-<img srcset='http://base/img.jpg'>
+ srcsetXMLVariationsCorrect = `Pre.
+Missing start quote: <img srcset=/img/small.jpg 200w /img/big.jpg 700w" alt="text"> src='http://base/img/foo.jpg'> FOO.
+<img srcset='http://base/img.jpg'>
schemaless: <img srcset='//img.jpg' src='//basic.jpg'>
schemaless2: <img srcset="//img.jpg" src="//basic.jpg2> POST
`
var (
absURLlBenchTests = []test{
- {h5JsContentDoubleQuote, corectOutputSrcHrefDq},
- {h5JsContentSingleQuote, corectOutputSrcHrefSq},
+ {h5JsContentDoubleQuote, correctOutputSrcHrefDq},
+ {h5JsContentSingleQuote, correctOutputSrcHrefSq},
{h5JsContentAbsURL, h5JsContentAbsURL},
{h5JsContentAbsURLSchemaless, h5JsContentAbsURLSchemaless},
}
xmlAbsURLBenchTests = []test{
- {h5XMLXontentAbsURL, correctOutputSrcHrefInXML},
+ {h5XMLContentAbsURL, correctOutputSrcHrefInXML},
{h5XMLContentGuarded, h5XMLContentGuarded},
}
apply(t.Errorf, tr, absURLTests)
}
-func TestAbsURLUnqoted(t *testing.T) {
+func TestAbsURLUnquoted(t *testing.T) {
tr := transform.New(NewAbsURLTransformer(testBaseURL))
apply(t.Errorf, tr, []test{