Add test for line anchor attributes with code fences
authorKaushal Modi <kaushal.modi@gmail.com>
Thu, 24 Feb 2022 19:12:45 +0000 (14:12 -0500)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Thu, 24 Feb 2022 21:54:49 +0000 (22:54 +0100)
Fixes https://github.com/gohugoio/hugo/issues/9385.

markup/goldmark/convert_test.go

index ecb308eba69349d2a84791d56ebba6f706ea70f1..2227d6187cb1998efbb7056fc53c40af2fd44a62 100644 (file)
@@ -278,6 +278,16 @@ func TestConvertAttributes(t *testing.T) {
                                "table style",
                        },
                },
+               {
+                       "Code block, CodeFences=true,lineanchors",
+                       func(conf *markup_config.Config) {
+                               withBlockAttributes(conf)
+                               conf.Highlight.CodeFences = true
+                               conf.Highlight.NoClasses = false
+                       },
+                       "```bash {linenos=table, anchorlinenos=true, lineanchors=org-coderef--xyz}\necho 'foo';\n```",
+                       "<div class=\"highlight\"><div class=\"chroma\">\n<table class=\"lntable\"><tr><td class=\"lntd\">\n<pre tabindex=\"0\" class=\"chroma\"><code><span class=\"lnt\" id=\"org-coderef--xyz-1\"><a style=\"outline: none; text-decoration:none; color:inherit\" href=\"#org-coderef--xyz-1\">1</a>\n</span></code></pre></td>\n<td class=\"lntd\">\n<pre tabindex=\"0\" class=\"chroma\"><code class=\"language-bash\" data-lang=\"bash\"><span class=\"line\"><span class=\"cl\"><span class=\"nb\">echo</span> <span class=\"s1\">&#39;foo&#39;</span><span class=\"p\">;</span>\n</span></span></code></pre></td></tr></table>\n</div>\n</div>",
+               },
                {
                        "Paragraph",
                        withBlockAttributes,