summaryrefslogtreecommitdiffstats
path: root/markup
diff options
context:
space:
mode:
Diffstat (limited to 'markup')
-rw-r--r--markup/asciidocext/convert_test.go2
-rw-r--r--markup/blackfriday/anchors.go2
-rw-r--r--markup/converter/converter.go3
-rw-r--r--markup/converter/hooks/hooks.go4
-rw-r--r--markup/goldmark/codeblocks/integration_test.go5
-rw-r--r--markup/goldmark/codeblocks/render.go4
-rw-r--r--markup/goldmark/convert.go28
-rw-r--r--markup/goldmark/convert_test.go5
-rw-r--r--markup/goldmark/goldmark_config/config.go7
-rw-r--r--markup/goldmark/images/integration_test.go9
-rw-r--r--markup/goldmark/internal/render/context.go9
-rw-r--r--markup/goldmark/links/integration_test.go113
-rw-r--r--markup/goldmark/links/transform.go57
-rw-r--r--markup/goldmark/render_hooks.go14
-rw-r--r--markup/goldmark/toc_test.go2
-rw-r--r--markup/highlight/chromalexers/chromalexers.go2
-rw-r--r--markup/highlight/highlight.go12
-rw-r--r--markup/highlight/highlight_test.go1
-rw-r--r--markup/highlight/integration_test.go2
-rw-r--r--markup/internal/attributes/attributes.go2
-rw-r--r--markup/markup.go6
-rw-r--r--markup/markup_test.go2
-rw-r--r--markup/org/convert_test.go2
-rw-r--r--markup/tableofcontents/integration_test.go2
24 files changed, 29 insertions, 266 deletions
diff --git a/markup/asciidocext/convert_test.go b/markup/asciidocext/convert_test.go
index 459686139..9ccc807f1 100644
--- a/markup/asciidocext/convert_test.go
+++ b/markup/asciidocext/convert_test.go
@@ -1,4 +1,4 @@
-// Copyright 2023 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
diff --git a/markup/blackfriday/anchors.go b/markup/blackfriday/anchors.go
index 90f65a64c..987f46fc6 100644
--- a/markup/blackfriday/anchors.go
+++ b/markup/blackfriday/anchors.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
diff --git a/markup/converter/converter.go b/markup/converter/converter.go
index 7c4898592..b66cb8730 100644
--- a/markup/converter/converter.go
+++ b/markup/converter/converter.go
@@ -89,7 +89,6 @@ func (nopConverter) Supports(feature identity.Identity) bool {
// another format, e.g. Markdown to HTML.
type Converter interface {
Convert(ctx RenderContext) (ResultRender, error)
- Supports(feature identity.Identity) bool
}
// ParseRenderer is an optional interface.
@@ -156,5 +155,3 @@ type RenderContext struct {
// GerRenderer provides hook renderers on demand.
GetRenderer hooks.GetRendererFunc
}
-
-var FeatureRenderHooks = identity.NewPathIdentity("markup", "renderingHooks")
diff --git a/markup/converter/hooks/hooks.go b/markup/converter/hooks/hooks.go
index c5be4d1f0..bdc38f119 100644
--- a/markup/converter/hooks/hooks.go
+++ b/markup/converter/hooks/hooks.go
@@ -20,7 +20,6 @@ import (
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/common/text"
"github.com/gohugoio/hugo/common/types/hstring"
- "github.com/gohugoio/hugo/identity"
"github.com/gohugoio/hugo/markup/internal/attributes"
)
@@ -89,12 +88,10 @@ type AttributesOptionsSliceProvider interface {
type LinkRenderer interface {
RenderLink(cctx context.Context, w io.Writer, ctx LinkContext) error
- identity.Provider
}
type CodeBlockRenderer interface {
RenderCodeblock(cctx context.Context, w hugio.FlexiWriter, ctx CodeblockContext) error
- identity.Provider
}
type IsDefaultCodeBlockRendererProvider interface {
@@ -123,7 +120,6 @@ type HeadingContext interface {
type HeadingRenderer interface {
// RenderHeading writes the rendered content to w using the data in w.
RenderHeading(cctx context.Context, w io.Writer, ctx HeadingContext) error
- identity.Provider
}
// ElementPositionResolver provides a way to resolve the start Position
diff --git a/markup/goldmark/codeblocks/integration_test.go b/markup/goldmark/codeblocks/integration_test.go
index 7f0201878..5597fc507 100644
--- a/markup/goldmark/codeblocks/integration_test.go
+++ b/markup/goldmark/codeblocks/integration_test.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
@@ -339,7 +339,6 @@ Attributes: {{ .Attributes }}|Options: {{ .Options }}|
}
func TestPanics(t *testing.T) {
-
files := `
-- config.toml --
[markup]
@@ -384,7 +383,6 @@ Common
b.AssertFileContent("public/p1/index.html", "Common")
})
}
-
}
// Issue 10835
@@ -421,5 +419,4 @@ Attributes: {{ .Attributes }}|Type: {{ .Type }}|
b.Assert(err, qt.Not(qt.IsNil))
b.Assert(err.Error(), qt.Contains, "p1.md:7:9\": failed to parse Markdown attributes; you may need to quote the values")
-
}
diff --git a/markup/goldmark/codeblocks/render.go b/markup/goldmark/codeblocks/render.go
index 5f053d278..5f479bf23 100644
--- a/markup/goldmark/codeblocks/render.go
+++ b/markup/goldmark/codeblocks/render.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
@@ -133,8 +133,6 @@ func (r *htmlRenderer) renderCodeBlock(w util.BufWriter, src []byte, node ast.No
cbctx,
)
- ctx.AddIdentity(cr)
-
if err != nil {
return ast.WalkContinue, herrors.NewFileErrorFromPos(err, cbctx.createPos())
}
diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go
index 56cc56fcd..de06bedff 100644
--- a/markup/goldmark/convert.go
+++ b/markup/goldmark/convert.go
@@ -17,8 +17,6 @@ package goldmark
import (
"bytes"
- "github.com/gohugoio/hugo/identity"
-
"github.com/gohugoio/hugo-goldmark-extensions/passthrough"
"github.com/gohugoio/hugo/markup/goldmark/codeblocks"
"github.com/gohugoio/hugo/markup/goldmark/goldmark_config"
@@ -213,8 +211,6 @@ func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
return md
}
-var _ identity.IdentitiesProvider = (*converterResult)(nil)
-
type parserResult struct {
doc any
toc *tableofcontents.Fragments
@@ -230,25 +226,17 @@ func (p parserResult) TableOfContents() *tableofcontents.Fragments {
type renderResult struct {
converter.ResultRender
- ids identity.Identities
-}
-
-func (r renderResult) GetIdentities() identity.Identities {
- return r.ids
}
type converterResult struct {
converter.ResultRender
tableOfContentsProvider
- identity.IdentitiesProvider
}
type tableOfContentsProvider interface {
TableOfContents() *tableofcontents.Fragments
}
-var converterIdentity = identity.KeyValueIdentity{Key: "goldmark", Value: "converter"}
-
func (c *goldmarkConverter) Parse(ctx converter.RenderContext) (converter.ResultParse, error) {
pctx := c.newParserContext(ctx)
reader := text.NewReader(ctx.Src)
@@ -262,8 +250,8 @@ func (c *goldmarkConverter) Parse(ctx converter.RenderContext) (converter.Result
doc: doc,
toc: pctx.TableOfContents(),
}, nil
-
}
+
func (c *goldmarkConverter) Render(ctx converter.RenderContext, doc any) (converter.ResultRender, error) {
n := doc.(ast.Node)
buf := &render.BufWriter{Buffer: &bytes.Buffer{}}
@@ -271,7 +259,6 @@ func (c *goldmarkConverter) Render(ctx converter.RenderContext, doc any) (conver
rcx := &render.RenderContextDataHolder{
Rctx: ctx,
Dctx: c.ctx,
- IDs: identity.NewManager(converterIdentity),
}
w := &render.Context{
@@ -285,9 +272,7 @@ func (c *goldmarkConverter) Render(ctx converter.RenderContext, doc any) (conver
return renderResult{
ResultRender: buf,
- ids: rcx.IDs.GetIdentities(),
}, nil
-
}
func (c *goldmarkConverter) Convert(ctx converter.RenderContext) (converter.ResultRender, error) {
@@ -302,17 +287,7 @@ func (c *goldmarkConverter) Convert(ctx converter.RenderContext) (converter.Resu
return converterResult{
ResultRender: renderResult,
tableOfContentsProvider: parseResult,
- IdentitiesProvider: renderResult.(identity.IdentitiesProvider),
}, nil
-
-}
-
-var featureSet = map[identity.Identity]bool{
- converter.FeatureRenderHooks: true,
-}
-
-func (c *goldmarkConverter) Supports(feature identity.Identity) bool {
- return featureSet[feature.GetIdentity()]
}
func (c *goldmarkConverter) newParserContext(rctx converter.RenderContext) *parserContext {
@@ -349,5 +324,4 @@ func toTypographicPunctuationMap(t goldmark_config.Typographer) map[extension.Ty
extension.RightAngleQuote: []byte(t.RightAngleQuote),
extension.Apostrophe: []byte(t.Apostrophe),
}
-
}
diff --git a/markup/goldmark/convert_test.go b/markup/goldmark/convert_test.go
index c97156f7a..266f0f9ab 100644
--- a/markup/goldmark/convert_test.go
+++ b/markup/goldmark/convert_test.go
@@ -1,4 +1,4 @@
-// Copyright 2023 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
@@ -483,7 +483,6 @@ noclasses=false
})
c.Run("Highlight lines, default config", func(c *qt.C) {
-
result := convertForConfig(c, cfgStrHighlichgtNoClasses, lines, `bash {linenos=table,hl_lines=[2 "4-5"],linenostart=3}`)
c.Assert(result, qt.Contains, "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre tabindex=\"0\" class=\"chroma\"><code><span class")
c.Assert(result, qt.Contains, "<span class=\"hl\"><span class=\"lnt\">4")
@@ -614,7 +613,6 @@ func unsafeConf() config.AllProvider {
unsafe = true
`)
return testconfig.GetTestConfig(nil, cfg)
-
}
func safeConf() config.AllProvider {
@@ -624,7 +622,6 @@ func safeConf() config.AllProvider {
unsafe = false
`)
return testconfig.GetTestConfig(nil, cfg)
-
}
func TestConvertCJK(t *testing.T) {
diff --git a/markup/goldmark/goldmark_config/config.go b/markup/goldmark/goldmark_config/config.go
index ba1874a18..1c393e3f4 100644
--- a/markup/goldmark/goldmark_config/config.go
+++ b/markup/goldmark/goldmark_config/config.go
@@ -73,9 +73,10 @@ var Default = Config{
// Config configures Goldmark.
type Config struct {
- Renderer Renderer
- Parser Parser
- Extensions Extensions
+ DuplicateResourceFiles bool
+ Renderer Renderer
+ Parser Parser
+ Extensions Extensions
}
type Extensions struct {
diff --git a/markup/goldmark/images/integration_test.go b/markup/goldmark/images/integration_test.go
index e8d1b880e..8b0ba99c1 100644
--- a/markup/goldmark/images/integration_test.go
+++ b/markup/goldmark/images/integration_test.go
@@ -39,10 +39,10 @@ This is an inline image: ![Inline Image](/inline.jpg). Some more text.
files = files + `-- layouts/_default/_markup/render-image.html --
{{ if .IsBlock }}
<figure class="{{ .Attributes.class }}">
- <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
+ <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}|{{ .Ordinal }}" />
</figure>
{{ else }}
- <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
+ <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}|{{ .Ordinal }}" />
{{ end }}
`
b := hugolib.NewIntegrationTestBuilder(
@@ -54,8 +54,8 @@ This is an inline image: ![Inline Image](/inline.jpg). Some more text.
).Build()
b.AssertFileContent("public/p1/index.html",
- "This is an inline image: \n\t<img src=\"/inline.jpg\" alt=\"Inline Image\" />\n. Some more text.</p>",
- "<figure class=\"b\">\n\t<img src=\"/block.jpg\" alt=\"Block Image\" />",
+ "This is an inline image: \n\t<img src=\"/inline.jpg\" alt=\"Inline Image|0\" />\n. Some more text.</p>",
+ "<figure class=\"b\">\n\t<img src=\"/block.jpg\" alt=\"Block Image|1\" />",
)
})
@@ -109,5 +109,4 @@ This is an inline image: ![Inline Image](/inline.jpg). Some more text.
b.AssertFileContent("public/p1/index.html", "<p class=\"b\"><img src=\"/block.jpg\" alt=\"Block Image\"></p>")
})
-
}
diff --git a/markup/goldmark/internal/render/context.go b/markup/goldmark/internal/render/context.go
index b18983ef3..578714339 100644
--- a/markup/goldmark/internal/render/context.go
+++ b/markup/goldmark/internal/render/context.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
@@ -17,7 +17,6 @@ import (
"bytes"
"math/bits"
- "github.com/gohugoio/hugo/identity"
"github.com/gohugoio/hugo/markup/converter"
)
@@ -59,13 +58,11 @@ func (ctx *Context) PopPos() int {
type ContextData interface {
RenderContext() converter.RenderContext
DocumentContext() converter.DocumentContext
- AddIdentity(id identity.Provider)
}
type RenderContextDataHolder struct {
Rctx converter.RenderContext
Dctx converter.DocumentContext
- IDs identity.Manager
}
func (ctx *RenderContextDataHolder) RenderContext() converter.RenderContext {
@@ -75,7 +72,3 @@ func (ctx *RenderContextDataHolder) RenderContext() converter.RenderContext {
func (ctx *RenderContextDataHolder) DocumentContext() converter.DocumentContext {
return ctx.Dctx
}
-
-func (ctx *RenderContextDataHolder) AddIdentity(id identity.Provider) {
- ctx.IDs.Add(id)
-}
diff --git a/markup/goldmark/links/integration_test.go b/markup/goldmark/links/integration_test.go
deleted file mode 100644
index 20d4d74b1..000000000
--- a/markup/goldmark/links/integration_test.go
+++ /dev/null
@@ -1,113 +0,0 @@
-package images_test
-
-import (
- "strings"
- "testing"
-
- "github.com/gohugoio/hugo/hugolib"
-)
-
-func TestDisableWrapStandAloneImageWithinParagraph(t *testing.T) {
- t.Parallel()
-
- filesTemplate := `
--- config.toml --
-[markup.goldmark.renderer]
- unsafe = false
-[markup.goldmark.parser]
-wrapStandAloneImageWithinParagraph = CONFIG_VALUE
-[markup.goldmark.parser.attribute]
- block = true
- title = true
--- content/p1.md --
----
-title: "p1"
----
-
-This is an inline image: ![Inline Image](/inline.jpg). Some more text.
-
-![Block Image](/block.jpg)
-{.b}
-
-
--- layouts/_default/single.html --
-{{ .Content }}
-`
-
- t.Run("With Hook, no wrap", func(t *testing.T) {
- files := strings.ReplaceAll(filesTemplate, "CONFIG_VALUE", "false")
- files = files + `-- layouts/_default/_markup/render-image.html --
-{{ if .IsBlock }}
-<figure class="{{ .Attributes.class }}">
- <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}|{{ .Ordinal }}" />
-</figure>
-{{ else }}
- <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}|{{ .Ordinal }}" />
-{{ end }}
-`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: false,
- },
- ).Build()
-
- b.AssertFileContent("public/p1/index.html",
- "This is an inline image: \n\t<img src=\"/inline.jpg\" alt=\"Inline Image|0\" />\n. Some more text.</p>",
- "<figure class=\"b\">\n\t<img src=\"/block.jpg\" alt=\"Block Image|1\" />",
- )
- })
-
- t.Run("With Hook, wrap", func(t *testing.T) {
- files := strings.ReplaceAll(filesTemplate, "CONFIG_VALUE", "true")
- files = files + `-- layouts/_default/_markup/render-image.html --
-{{ if .IsBlock }}
-<figure class="{{ .Attributes.class }}">
- <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
-</figure>
-{{ else }}
- <img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" />
-{{ end }}
-`
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: false,
- },
- ).Build()
-
- b.AssertFileContent("public/p1/index.html",
- "This is an inline image: \n\t<img src=\"/inline.jpg\" alt=\"Inline Image\" />\n. Some more text.</p>",
- "<p class=\"b\">\n\t<img src=\"/block.jpg\" alt=\"Block Image\" />\n</p>",
- )
- })
-
- t.Run("No Hook, no wrap", func(t *testing.T) {
- files := strings.ReplaceAll(filesTemplate, "CONFIG_VALUE", "false")
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: false,
- },
- ).Build()
-
- b.AssertFileContent("public/p1/index.html", "<p>This is an inline image: <img src=\"/inline.jpg\" alt=\"Inline Image\">. Some more text.</p>\n<img src=\"/block.jpg\" alt=\"Block Image\" class=\"b\">")
- })
-
- t.Run("No Hook, wrap", func(t *testing.T) {
- files := strings.ReplaceAll(filesTemplate, "CONFIG_VALUE", "true")
- b := hugolib.NewIntegrationTestBuilder(
- hugolib.IntegrationTestConfig{
- T: t,
- TxtarString: files,
- NeedsOsFS: false,
- },
- ).Build()
-
- b.AssertFileContent("public/p1/index.html", "<p class=\"b\"><img src=\"/block.jpg\" alt=\"Block Image\"></p>")
- })
-
-}
diff --git a/markup/goldmark/links/transform.go b/markup/goldmark/links/transform.go
deleted file mode 100644
index 2a7815b70..000000000
--- a/markup/goldmark/links/transform.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package images
-
-import (
- "github.com/yuin/goldmark/ast"
- "github.com/yuin/goldmark/parser"
- "github.com/yuin/goldmark/text"
-)
-
-type (
- linksExtension struct {
- wrapStandAloneImageWithinParagraph bool
- }
-)
-
-const (
- // Used to signal to the rendering step that an image is used in a block context.
- // Dont's change this; the prefix must match the internalAttrPrefix in the root goldmark package.
- AttrIsBlock = "_h__isBlock"
-)
-
-type Transformer struct {
- wrapStandAloneImageWithinParagraph bool
-}
-
-// Transform transforms the provided Markdown AST.
-func (t *Transformer) Transform(doc *ast.Document, reader text.Reader, pctx parser.Context) {
- ast.Walk(doc, func(node ast.Node, enter bool) (ast.WalkStatus, error) {
- if !enter {
- return ast.WalkContinue, nil
- }
-
- if n, ok := node.(*ast.Image); ok {
- parent := n.Parent()
-
- if !t.wrapStandAloneImageWithinParagraph {
- isBlock := parent.ChildCount() == 1
- if isBlock {
- n.SetAttributeString(AttrIsBlock, true)
- }
-
- if isBlock && parent.Kind() == ast.KindParagraph {
- for _, attr := range parent.Attributes() {
- // Transfer any attribute set down to the image.
- // Image elements does not support attributes on its own,
- // so it's safe to just set without checking first.
- n.SetAttribute(attr.Name, attr.Value)
- }
- grandParent := parent.Parent()
- grandParent.ReplaceChild(grandParent, parent, n)
- }
- }
-
- }
-
- return ast.WalkContinue, nil
- })
-}
diff --git a/markup/goldmark/render_hooks.go b/markup/goldmark/render_hooks.go
index ecdd7f91e..8dcdc39c3 100644
--- a/markup/goldmark/render_hooks.go
+++ b/markup/goldmark/render_hooks.go
@@ -197,8 +197,6 @@ func (r *hookedRenderer) renderImage(w util.BufWriter, source []byte, node ast.N
},
)
- ctx.AddIdentity(lr)
-
return ast.WalkContinue, err
}
@@ -284,11 +282,6 @@ func (r *hookedRenderer) renderLink(w util.BufWriter, source []byte, node ast.No
},
)
- // TODO(bep) I have a working branch that fixes these rather confusing identity types,
- // but for now it's important that it's not .GetIdentity() that's added here,
- // to make sure we search the entire chain on changes.
- ctx.AddIdentity(lr)
-
return ast.WalkContinue, err
}
@@ -353,11 +346,6 @@ func (r *hookedRenderer) renderAutoLink(w util.BufWriter, source []byte, node as
},
)
- // TODO(bep) I have a working branch that fixes these rather confusing identity types,
- // but for now it's important that it's not .GetIdentity() that's added here,
- // to make sure we search the entire chain on changes.
- ctx.AddIdentity(lr)
-
return ast.WalkContinue, err
}
@@ -443,8 +431,6 @@ func (r *hookedRenderer) renderHeading(w util.BufWriter, source []byte, node ast
},
)
- ctx.AddIdentity(hr)
-
return ast.WalkContinue, err
}
diff --git a/markup/goldmark/toc_test.go b/markup/goldmark/toc_test.go
index 1b846877b..96983dfa6 100644
--- a/markup/goldmark/toc_test.go
+++ b/markup/goldmark/toc_test.go
@@ -1,4 +1,4 @@
-// Copyright 2023 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
diff --git a/markup/highlight/chromalexers/chromalexers.go b/markup/highlight/chromalexers/chromalexers.go
index 41fd76261..6ab4a7bbe 100644
--- a/markup/highlight/chromalexers/chromalexers.go
+++ b/markup/highlight/chromalexers/chromalexers.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
diff --git a/markup/highlight/highlight.go b/markup/highlight/highlight.go
index 85ea74124..a284b5981 100644
--- a/markup/highlight/highlight.go
+++ b/markup/highlight/highlight.go
@@ -27,7 +27,6 @@ import (
"github.com/alecthomas/chroma/v2/styles"
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/common/text"
- "github.com/gohugoio/hugo/identity"
"github.com/gohugoio/hugo/markup/converter/hooks"
"github.com/gohugoio/hugo/markup/highlight/chromalexers"
"github.com/gohugoio/hugo/markup/internal/attributes"
@@ -146,13 +145,6 @@ func (h chromaHighlighter) IsDefaultCodeBlockRenderer() bool {
return true
}
-var id = identity.NewPathIdentity("chroma", "highlight")
-
-// GetIdentity is for internal use.
-func (h chromaHighlighter) GetIdentity() identity.Identity {
- return id
-}
-
// HighlightResult holds the result of an highlighting operation.
type HighlightResult struct {
innerLow int
@@ -188,7 +180,7 @@ func highlight(fw hugio.FlexiWriter, code, lang string, attributes []attributes.
if lexer == nil {
if cfg.Hl_inline {
- fmt.Fprint(w, fmt.Sprintf("<code%s>%s</code>", inlineCodeAttrs(lang), gohtml.EscapeString(code)))
+ fmt.Fprintf(w, "<code%s>%s</code>", inlineCodeAttrs(lang), gohtml.EscapeString(code))
} else {
preWrapper := getPreWrapper(lang, w)
fmt.Fprint(w, preWrapper.Start(true, ""))
@@ -278,8 +270,6 @@ func (p *preWrapper) Start(code bool, styleAttr string) string {
}
func inlineCodeAttrs(lang string) string {
- if lang == "" {
- }
return fmt.Sprintf(` class="code-inline language-%s"`, lang)
}
diff --git a/markup/highlight/highlight_test.go b/markup/highlight/highlight_test.go
index 662f07c93..732dbfa64 100644
--- a/markup/highlight/highlight_test.go
+++ b/markup/highlight/highlight_test.go
@@ -87,7 +87,6 @@ User-Agent: foo
result, _ := h.Highlight(lines, "bash", "")
c.Assert(result, qt.Contains, "<span class=\"lnt\" id=\"2\"><a class=\"lnlinks\" href=\"#2\">2</a>\n</span>")
- result, _ = h.Highlight(lines, "bash", "lineanchors=test")
result, _ = h.Highlight(lines, "bash", "anchorlinenos=false,hl_lines=2")
c.Assert(result, qt.Not(qt.Contains), "id=\"2\"")
})
diff --git a/markup/highlight/integration_test.go b/markup/highlight/integration_test.go
index ce6705f02..b53b585c0 100644
--- a/markup/highlight/integration_test.go
+++ b/markup/highlight/integration_test.go
@@ -1,4 +1,4 @@
-// Copyright 2022 The Hugo Authors. All rights reserved.
+// Copyright 2024 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.
diff --git a/markup/in