From 3d2099994b33f49a247776986f926039f4b4c075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sat, 20 Mar 2021 16:36:30 +0100 Subject: [PATCH] Attributes for code fences should be placed after the lang indicator only Fixes #8313 --- .../en/getting-started/configuration-markup.md | 8 ++++++++ markup/goldmark/convert_test.go | 12 +++++++++++- .../internal/extensions/attributes/attributes.go | 12 +++++++++--- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/docs/content/en/getting-started/configuration-markup.md b/docs/content/en/getting-started/configuration-markup.md index ca88d555750..14a23b73424 100644 --- a/docs/content/en/getting-started/configuration-markup.md +++ b/docs/content/en/getting-started/configuration-markup.md @@ -68,6 +68,14 @@ There are some current limitations: For tables you can currently only apply it t {.list} ``` +Note that attributes in [code fences](/content-management/syntax-highlighting/#highlighting-in-code-fences) must come after the opening tag, with any other highlighting processing instruction, e.g.: + +```` +```go {.myclass linenos=table,hl_lines=[8,"15-17"],linenostart=199} +// ... code +``` +```` + autoHeadingIDType ("github") {{< new-in "0.62.2" >}} : The strategy used for creating auto IDs (anchor names). Available types are `github`, `github-ascii` and `blackfriday`. `github` produces GitHub-compatible IDs, `github-ascii` will drop any non-Ascii characters after accent normalization, and `blackfriday` will make the IDs work as with [Blackfriday](#blackfriday), the default Markdown engine before Hugo 0.60. Note that if Goldmark is your default Markdown engine, this is also the strategy used in the [anchorize](/functions/anchorize/) template func. diff --git a/markup/goldmark/convert_test.go b/markup/goldmark/convert_test.go index c7367dd0150..2b66a191003 100644 --- a/markup/goldmark/convert_test.go +++ b/markup/goldmark/convert_test.go @@ -242,9 +242,19 @@ func TestConvertAttributes(t *testing.T) { withBlockAttributes(conf) conf.Highlight.CodeFences = true }, - "```bash\necho 'foo';\n````\n{.myclass id=\"myid\"}", + "```bash {.myclass id=\"myid\"}\necho 'foo';\n````\n", "