From: Bjørn Erik Pedersen Date: Tue, 23 Feb 2021 17:04:05 +0000 (+0100) Subject: markup: Handle attribute lists in code fences X-Git-Tag: v0.82.0~26 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=aed7df62a811b07b73ec5cbbf03e69e4bbf00919;p=brevno-suite%2Fhugo markup: Handle attribute lists in code fences Fixes #8278 --- diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go index 629e2b15..639fddac 100644 --- a/markup/goldmark/convert.go +++ b/markup/goldmark/convert.go @@ -22,6 +22,7 @@ import ( "runtime/debug" "github.com/gohugoio/hugo/markup/goldmark/internal/extensions/attributes" + "github.com/yuin/goldmark/ast" "github.com/gohugoio/hugo/identity" @@ -321,7 +322,28 @@ func newHighlighting(cfg highlight.Config) goldmark.Extender { highlight.WriteCodeTag(w, language) return } - w.WriteString(`
`) + + w.WriteString(`
") return } diff --git a/markup/goldmark/convert_test.go b/markup/goldmark/convert_test.go index d35d4d1f..c7367dd0 100644 --- a/markup/goldmark/convert_test.go +++ b/markup/goldmark/convert_test.go @@ -226,6 +226,25 @@ func TestConvertAttributes(t *testing.T) { "> foo\n> bar\n{#id .className attrName=attrValue class=\"class1 class2\"}\n", "

foo\nbar

\n
\n", }, + /*{ + // TODO(bep) this needs an upstream fix, see https://github.com/yuin/goldmark/issues/195 + "Code block, CodeFences=false", + func(conf *markup_config.Config) { + withBlockAttributes(conf) + conf.Highlight.CodeFences = false + }, + "```bash\necho 'foo';\n```\n{.myclass}", + "TODO", + },*/ + { + "Code block, CodeFences=true", + func(conf *markup_config.Config) { + withBlockAttributes(conf) + conf.Highlight.CodeFences = true + }, + "```bash\necho 'foo';\n````\n{.myclass id=\"myid\"}", + "
')
 	} else {