Age | Commit message (Collapse) | Author |
|
Using x/tools/cmd/deadcode
|
|
Closes #11698
|
|
This introduces a more automatic way of increasing the log levels for deprecation log statements based on the version it was deprecated.
The thresholds are a little arbitrary, but
* We log INFO for 6 releases
* We log WARN for another 6 releases
* THen ERROR (failing the build)
This should give theme authors plenty of time to catch up without having the log filled with warnings.
|
|
Removes emoji code conversion from the page and shortcode parsers. Emoji
codes in markdown are now passed to Goldmark, where the goldmark-emoji
extension converts them to decimal numeric character references.
This disables emoji rendering for the alternate content formats: html,
asciidoc, org, pandoc, and rst.
Fixes #7332
Fixes #11587
Closes #11598
|
|
Which supports all the existing actions: resize, crop, fit, fill.
But it also allows plain format conversions:
```
{{ $img = $img.Process "webp" }}
```
Which will be a simple re-encoding of the source image.
Fixes #11483
|
|
Fixes #11327
|
|
We will now try
1. cacheDir (or, commonly set in environment as `HUGO_CACHEDIR`)
2. if on Netlify we use `/opt/build/cache/hugo_cache/`
3. os.UserCacheDir
4. A temp dir
Storing the cache, especially the module cache, in a temporary idea has had lots of hard to debug issues, especially on MacOS,
which this commit tries to fix.
This should also make it easier to locate the Hugo cache:
>UserCacheDir returns the default root directory to use for user-specific cached data. Users should create their own
application-specific subdirectory within this one and use that.
>
>On Unix systems, it returns $XDG_CACHE_HOME as specified by
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.cache. On Darwin, it
returns $HOME/Library/Caches. On Windows, it returns %LocalAppData%. On Plan 9, it returns $home/lib/cache.
>
>If the location cannot be determined (for example, $HOME is not defined), then it will return an error.
Fixes #11286
Fixes #11291
|
|
Fixes #10064
|
|
Fixes #11204
|
|
|
|
|
|
Fixes #11124
|
|
Change the default cache directory to `$TMPDIR/hugo_cache_$USER`, so
that multi-user systems do not have caches that interfere with each
other. The other cache-choosing logic (e.g. Netlify exceptions,
configuration options) are not affected.
Fixes #7391
|
|
```
RelURL-10 159ns ± 5% 18ns ± 4% -88.89% (p=0.029 n=4+4)
AbsURL/relurl-10 532ns ± 0% 537ns ± 0% +1.09% (p=0.029 n=4+4)
AbsURL/absurl-10 142ns ± 0% 4ns ± 3% -96.91% (p=0.029 n=4+4)
name old alloc/op new alloc/op delta
RelURL-10 144B ± 0% 0B -100.00% (p=0.029 n=4+4)
AbsURL/relurl-10 544B ± 0% 544B ± 0% ~ (all equal)
AbsURL/absurl-10 144B ± 0% 0B -100.00% (p=0.029 n=4+4)
name old allocs/op new allocs/op delta
RelURL-10 1.00 ± 0% 0.00 -100.00% (p=0.029 n=4+4)
AbsURL/relurl-10 10.0 ± 0% 10.0 ± 0% ~ (all equal)
AbsURL/absurl-10 1.00 ± 0% 0.00 -100.00% (p=0.029 n=4+4)
```
|
|
|
|
|
|
|
|
Fixes #11080
|
|
|
|
|
|
|
|
Primary motivation is documentation, but it will also hopefully simplify the code.
Also,
* Lower case the default output format names; this is in line with the custom ones (map keys) and how
it's treated all the places. This avoids doing `stringds.EqualFold` everywhere.
Closes #10896
Closes #10620
|
|
Note that this is a test fix only.
|
|
|
|
https://pkg.go.dev/io/ioutil is deprecated since Go 1.16.
|
|
Updates #10691
|
|
Note that this is backed by a LRU cache (which we soon shall see more usage of), so if you're a heavy user of cached partials it may be evicted and
refreshed if needed. But in most cases every partial is only invoked once.
This commit also adds a timeout (the global `timeout` config option) to make infinite recursion in partials
easier to reason about.
```
name old time/op new time/op delta
IncludeCached-10 8.92ms ± 0% 8.48ms ± 1% -4.87% (p=0.016 n=4+5)
name old alloc/op new alloc/op delta
IncludeCached-10 6.65MB ± 0% 5.17MB ± 0% -22.32% (p=0.002 n=6+6)
name old allocs/op new allocs/op delta
IncludeCached-10 117k ± 0% 71k ± 0% -39.44% (p=0.002 n=6+6)
```
Closes #4086
Updates #9588
|
|
Closes #10548
|
|
Fixes #10534
|
|
Fixes #9932
Fixes #9931
|
|
Fixes #9994
|
|
This commit replaces the main part of `helpers.StripHTML` with Go's implementation in its html/template package.
It's a little slower, but correctness is more important:
```bash
BenchmarkStripHTMLOld-10 680316 1764 ns/op 728 B/op 4 allocs/op
BenchmarkStripHTMLNew-10 384520 3099 ns/op 2089 B/op 10 allocs/op
```
Fixes #9199
Fixes #9909
Closes #9410
|
|
Implemented by most Resource objects, but not Page (for now).
Fixes #9313
|
|
* Add file context to minifier errors when publishing
* Misc fixes (see issues)
* Allow custom server error template in layouts/server/error.html
To get to this, this commit also cleans up and simplifies the code surrounding errors and files. This also removes the usage of `github.com/pkg/errors`, mostly because of https://github.com/pkg/errors/issues/223 -- but also because most of this is now built-in to Go.
Fixes #9852
Fixes #9857
Fixes #9863
|
|
See #9626
|
|
Do this by announcing/listen on the local address before we start the server.
|
|
Updates #9687
|
|
You can now create custom hook templates for code blocks, either one for all (`render-codeblock.html`) or for a given code language (e.g. `render-codeblock-go.html`).
We also used this new hook to add support for diagrams in Hugo:
* Goat (Go ASCII Tool) is built-in and enabled by default; just create a fenced code block with the language `goat` and start draw your Ascii diagrams.
* Another popular alternative for diagrams in Markdown, Mermaid (supported by GitHub), can also be implemented with a simple template. See the Hugo documentation for more information.
Updates #7765
Closes #9538
Fixes #9553
Fixes #8520
Fixes #6702
Fixes #9558
|
|
Improve handling of existing hyphens in input to UnicodeSanitize.
This commit accomplishes three things:
1. Explicitly allow hyphens
2. Avoid appending a hyphen if a preceeding hyphen is found
3. Avoid prepending a hyphen if a trailing hyphen is found
Fixes #7288
|
|
The function printIfNotPrinted() defined for DistinctLogger unlocked the mutex within
the logger only after the print() function ran. If print panics, the mutex would stay
locked and future attempts to read or write from the logger mutex would cause the goroutine
to hang indefinitely.
Deferred the unlocking of the mutex to prevent this. Also, put l.m[key] before the print()
call since this will prevent another bug where the same warning potentially gets logged
multiple times if the print() call panics.
Fixes #9380
|
|
|
|
Fixes #9357
Fixes #9359
|
|
Closes #9350
|
|
This ommmit contains some security hardening measures for the Hugo build runtime.
There are some rarely used features in Hugo that would be good to have disabled by default. One example would be the "external helpers".
For `asciidoctor` and some others we use Go's `os/exec` package to start a new process.
These are a predefined set of binary names, all loaded from `PATH` and with a predefined set of arguments. Still, if you don't use `asciidoctor` in your project, you might as well have it turned off.
You can configure your own in the new `security` configuration section, but the defaults are configured to create a minimal amount of site breakage. And if that do happen, you will get clear instructions in the loa about what to do.
The default configuration is listed below. Note that almost all of these options are regular expression _whitelists_ (a string or a slice); the value `none` will block all.
```toml
[security]
enableInlineShortcodes = false
[security.exec]
allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']
[security.funcs]
getenv = ['^HUGO_']
[security.http]
methods = ['(?i)GET|POST']
urls = ['.*']
```
|
|
This should be faster for all of our use cases (small string slices), but more important, it makes UniqueStringsReuse allocation free.
```bash
name old time/op new time/op delta
UniqueStrings/Safe-16 776ns ± 0% 305ns ± 0% -60.68% (p=0.029 n=4+4)
UniqueStrings/Reuse_slice-16 621ns ± 3% 174ns ± 0% -72.01% (p=0.029 n=4+4)
UniqueStrings/Reuse_slice_sorted-16 319ns ± 4% 313ns ± 0% -2.01% (p=0.029 n=4+4)
name old alloc/op new alloc/op delta
UniqueStrings/Safe-16 224B ± 0% 128B ± 0% -42.86% (p=0.029 n=4+4)
UniqueStrings/Reuse_slice-16 96.0B ± 0% 0.0B -100.00% (p=0.029 n=4+4)
UniqueStrings/Reuse_slice_sorted-16 24.0B ± 0% 24.0B ± 0% ~ (all equal)
name old allocs/op new allocs/op delta
UniqueStrings/Safe-16 7.00 ± 0% 1.00 ± 0% -85.71% (p=0.029 n=4+4)
UniqueStrings/Reuse_slice-16 6.00 ± 0% 0.00 -100.00% (p=0.029 n=4+4)
UniqueStrings/Reuse_slice_sorted-16 1.00 ± 0% 1.00 ± 0% ~ (all equal)
```
|
|
|
|
This commit started out investigating a `concurrent map read write` issue, ending by replacing the map with a struct.
This is easier to reason about, and it's more effective:
```
name old time/op new time/op delta
SiteNew/Regular_Deep_content_tree-16 71.5ms ± 3% 69.4ms ± 5% ~ (p=0.200 n=4+4)
name old alloc/op new alloc/op delta
SiteNew/Regular_Deep_content_tree-16 29.7MB ± 0% 27.9MB ± 0% -5.82% (p=0.029 n=4+4)
name old allocs/op new allocs/op delta
SiteNew/Regular_Deep_content_tree-16 313k ± 0% 303k ± 0% -3.35% (p=0.029 n=4+4)
```
See #8749
|
|
|
|
Re-add the additional environment checks to determine if its Netlify. Seems that Cloudflare also sets `NETLIFY=true`.
This makes it look, basically, like a variant of the conditional we had before we started fixing this, but I have checked this logic on Netlify now and it should work.
Fixes #8714
|
|
Fixes #8710
|