176 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 7b5199fdef all: Run modernize -fix ./... 2026-08-20 21:56:40 +02:00
Bjørn Erik Pedersen ce1a7e0bce markup/highlight: Escape lang in default code block rendering 2026-06-18 18:14:40 +02:00
Joe Mooring ca68936d61 all: Adjust tests for deprecated link and image render hook settings 2026-06-01 15:52:34 +02:00
Joe Mooring c36608c584 markup/goldmark/codeblocks: Always split Chroma options into .Options
Closes #14909
2026-05-19 12:23:42 +02:00
Bjørn Erik Pedersen a20cb5b1c0 Revert "markup/tableofcontents: Skip empty TOC levels"
This reverts commit 7d4af7a179.

Closes #14898
2026-05-14 19:46:41 +02:00
Alexandre Vaz 7d4af7a179 markup/tableofcontents: Skip empty TOC levels
Fixes #7128
2026-05-12 19:02:23 +02:00
Rayan Salhab 694906f6f1 markup/goldmark: Unwrap inner HTML for plain code blocks
Fixes #14820
2026-05-09 11:41:18 +02:00
Bjørn Erik Pedersen 8b00030b34 Fix panic when passthrough elements are used in headings
Fixes #14677

Co-Authored-By: xingzihai <1315258019@qq.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-08 15:03:05 +02:00
Bjørn Erik Pedersen 161d0d4757 Fix RenderShortcodes leaking context markers when indented
Strip leading whitespace from Hugo context marker lines before
Goldmark parsing to prevent them from being treated as indented
code blocks.

Fixes #12457

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 22:05:42 +02:00
Bjørn Erik Pedersen 45e4596630 Strip nested page context markers from standalone RenderShortcodes
Fixes #14732

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 19:27:40 +02:00
Bjørn Erik Pedersen 4e91e14cb0 Fix some recently introduced Position issues
Fixes #14710
2026-04-04 14:53:20 +02:00
Bjørn Erik Pedersen dc9b51d2e2 markup/goldmark: Fix double-escaping of ampersands in link URLs
The XSS fix in 479fe6c65 accidentally called util.EscapeHTML twice
on link destinations, causing `&` to render as `&amp;amp;` instead
of `&amp;`.

Fixes #14715

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-04 14:52:29 +02:00
Bjørn Erik Pedersen 481baa0896 all: Replace NewIntegrationTestBuilder with Test/TestE/TestRunning 2026-04-03 21:17:45 +02:00
Bjørn Erik Pedersen 303e443ea7 Improve and extend .Position handling in Goldmark render hooks
Goldmark v1.8 reports source positions in render hooks.
Use this to build a source map that translates Goldmark positions back to
the original content source.

Now all render hooks' context object implenent the `BaseContext` interface:

```go
type BaseContext interface {
	Position() Position
	Page() any
	PageInner() any
	Ordinal() int
}
```

Closes #14663

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 19:30:28 +02:00
Bjørn Erik Pedersen 638262cec3 markup/goldmark: Clean up test 2026-04-01 17:05:08 +02:00
Bjørn Erik Pedersen 479fe6c654 Fix potential content XSS by escaping dangerous URLs in links and images
* This issue in question was fixed upstream in https://github.com/yuin/goldmark/releases/tag/v1.8.2
* We do, however, have a copy of the affected functions, used as fallbacks when no render hook are defined for e.g. links and images, so we need to port these fixes to our copy of the affected functions.
2026-04-01 14:23:24 +02:00
Bjørn Erik Pedersen e3108225bf all: Run go fix ./... 2026-03-07 18:30:42 +01:00
Joe Mooring 19ab3f581c all: Change site to project where appropriate
Closes #14504
2026-02-12 20:52:56 +01:00
Bjørn Erik Pedersen 608ed09a0a Rename common/maps to common/hmaps (#14384)
Go's stdlid now has a maps package, which is very useful. We have been using imports on the form `xmaps "maps"`, but auto import tools doesn't handle this, which is annoying.

I have been thinking about this for some time, but have been holding back because of all the import changes. However, now is a good time to do this, with very little unmerged code.
2026-01-16 11:47:46 +01:00
Bjørn Erik Pedersen 3073fd5ccf testing: Replace legacy config.toml with hugo.toml in most tests 2025-11-27 12:08:08 +01:00
Bjørn Erik Pedersen b9b304a126 testing: Port integration tests to new templates structure
As introduced in  v0.146.0. Keep some legecy test to preserve backwards compatibility.
2025-11-27 12:00:15 +01:00
Bjørn Erik Pedersen 4c7a78f5ca testing: Revise usage of b.N and b.Loop() in benchmarks 2025-11-07 13:33:39 +01:00
Bjørn Erik Pedersen 91eac9e573 all: Fix some benchmarks broken by modernize
It's not possible to use `b.Loop()` when `b.N` is used to prepare test data.

See 264022a75a
See #14107
2025-11-06 10:43:12 +01:00
Bjørn Erik Pedersen 04650ce778 all: Run modernize -fix ./...
Closes #14107
2025-11-05 21:05:42 +01:00
Bjørn Erik Pedersen 264022a75a Add roles and versions as new dimensions (in addition to language)
See the main issue #13776 for details.

Fixes #519
Fixes #13680
Fixes #13663
Fixes #13776
Fixes #13855
Fixes #13648
Fixes #13996
Fixes #14001
Fixes #14031
Fixes #13818
Fixes #13196
2025-11-05 20:39:25 +01:00
Joe Mooring 1b4dd436dd markup/goldmark: Align blockquote default output with Goldmark
Closes #14046
2025-10-14 09:38:29 +02:00
Joe Mooring b462980ac2 markup/goldmark: Enhance footnote extension with backlinkHTML option
This commit introduces a new option, backlinkHTML, to the Goldmark
footnote extension. This allows users to the set custom text for
footnote backlink anchors.

Closes #11434
2025-09-29 12:21:17 +02:00
Joe Mooring 47678d8cbd markup/goldmark: Enhance footnote extension with auto-prefixing option
This commit introduces a new option, enableAutoIDPrefix, to the Goldmark
footnote extension. When enabled, it prepends a unique prefix to
footnote IDs, preventing clashes when multiple documents are rendered
together. This prefix is unique to each logical path, which means that
the prefix is not unique across content dimensions such as language.
This change also refactors the extension's configuration from a boolean
to a struct.

Closes #8045
2025-09-27 18:16:42 +02:00
Joe Mooring 61482cfab6 markup/goldmark: Apply Hugo Goldmark Extras when rendering TOC
Closes #12605
2025-08-14 22:39:14 +02:00
Joe Mooring 5fdcc09062 markup/goldmark: Sanitize TOC heading titles
Fixes #13401
2025-08-13 11:23:30 +02:00
Joe Mooring 84b31721bf markup/goldmark: Change link and image render hook enablement to enums
Closes #13535
2025-07-07 11:19:34 +02:00
Bjørn Erik Pedersen 83cfdd78ca Reimplement and simplify Hugo's template system
See #13541 for details.

Fixes #13545
Fixes #13515
Closes #7964
Closes #13365
Closes #12988
Closes #4891
2025-04-06 20:59:41 +02:00
Bjørn Erik Pedersen 521911a576 all: Run modernize -fix ./... 2025-02-26 11:44:25 +01:00
Bjørn Erik Pedersen 494e88abf6 markup/goldmark: Fix panic on empty Markdown header
Fixes #13416
2025-02-18 11:12:39 +01:00
Bjørn Erik Pedersen 85c1727748 markup/goldmark: Fix panic on stray attribute nodes 2025-02-17 17:19:53 +01:00
Bjørn Erik Pedersen 641403f7de Fix Position for passthrough hooks
Fixes #13406
2025-02-17 12:23:49 +01:00
Bjørn Erik Pedersen 24cc25552f Fix auto generated header ids so they don't contain e.g. hyperlink destinations (note)
This makes the header ids match the newly added dt ids.

Also make sure newlines are preserved in hooks' `.PlainText`.

Fixes #13405
Fixes #13410
2025-02-17 12:23:49 +01:00
Bjørn Erik Pedersen 157d3703c3 Add autoID for definition terms
Fixes #13403
See #11566

Co-authored-by: Joe Mooring <joe@mooring.com>
2025-02-16 20:55:27 +01:00
Joe Mooring e08d9af21e markup/goldmark: Trim space from blockquote render hook text
Closes #13302
2025-01-24 19:58:45 +01:00
Patrice Chalin f704d75699 markup/goldmark: Fix typo in func comment 2025-01-22 14:57:24 +01:00
Bjørn Erik Pedersen 6aa72acaf9 Fix render hook's PlainText with typographer extension enabled
Fixes #13286
Fixes #13292
2025-01-22 12:49:25 +01:00
Bjørn Erik Pedersen 9885e7020d Improve assert 2025-01-22 09:44:26 +01:00
Bjørn Erik Pedersen 91101d24f2 Improve assertions 2025-01-22 09:44:26 +01:00
Bjørn Erik Pedersen 637995ba8f Also handle inline HTML comments 2025-01-22 09:44:26 +01:00
Bjørn Erik Pedersen f1de5d2a04 Do not warn on potentially unsafe HTML comments when unsafe=false
We will still not render these comments, so from a safety perspective this is the same, but HTML comments are very common also inside Markdown and too useful to throw away.

Updates #13278
2025-01-22 09:44:26 +01:00
Joe Mooring 34373407b7 markup/goldmark: Fix blockquote render hook text parsing
Fixes #12913
Fixes #13119
2024-12-10 09:43:33 +01:00
Joe Mooring 54398f8d57 tpl/tplimpl: Escape Markdown attributes in render hooks and shortcodes 2024-12-09 17:58:57 +01:00
Joe Mooring b529859008 markup/tableofcontents: Cast Fragments.ToHTML args to int
Closes #13107
2024-12-04 21:37:06 +01:00
Bjørn Erik Pedersen d4de780edc Fix extra newline/paragraphs issue with .RenderShortcodes
Fixes #13051
2024-11-16 17:51:11 +01:00
Bjørn Erik Pedersen 588c9019cf deps: Upgrade github.com/yuin/goldmark v1.7.4 => v1.7.8
Closes #12958
2024-11-14 14:31:04 +01:00