diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index fc4a515f72..1f75799900 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -1511,4 +1511,12 @@ func TestCodeblockLanguageStripping(t *testing.T) { "```", `
fn main() {}
`)
+
+ // No language identifier
+ test(
+ "```\n"+
+ "fn main() {}\n"+
+ "```",
+ `fn main() {}
+`)
}
diff --git a/modules/markup/markdown/transform_codeblock_lang.go b/modules/markup/markdown/transform_codeblock_lang.go
index 2c90373c4e..5263ec4ffc 100644
--- a/modules/markup/markdown/transform_codeblock_lang.go
+++ b/modules/markup/markdown/transform_codeblock_lang.go
@@ -11,6 +11,9 @@ import (
)
func (g *ASTTransformer) transformCodeblockLanguage(v *ast.FencedCodeBlock, reader text.Reader) {
+ if v.Info == nil {
+ return
+ }
src := reader.Source()
info := v.Info.Segment.Value(src)
// Strip language after commas