diff --git a/markup/goldmark/convert.go b/markup/goldmark/convert.go index 629e2b15a..639fddace 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 d35d4d1fd..c7367dd01 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 {