diff --git a/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs b/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs index 2fca4e4b7..807d601b0 100644 --- a/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs +++ b/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs @@ -81,22 +81,10 @@ protected override void Write(LlmMarkdownRenderer renderer, HeadingBlock obj) { renderer.EnsureBlockSpacing(); renderer.WriteLine(); - - var headingText = ExtractHeadingText(obj); - renderer.Write(new string('#', obj.Level)); renderer.Write(" "); - renderer.WriteLine(headingText); - } - - private static string ExtractHeadingText(HeadingBlock heading) - { - if (heading.Inline == null) - return string.Empty; - return heading.Inline.Descendants() - .OfType() - .Select(l => l.Content.ToString()) - .Aggregate(string.Empty, (current, text) => current + text); + if (obj.Inline is not null) + renderer.WriteChildren(obj.Inline); } } diff --git a/tests/authoring/LlmMarkdown/LlmMarkdownOutput.fs b/tests/authoring/LlmMarkdown/LlmMarkdownOutput.fs index 275def95d..97d1f4f31 100644 --- a/tests/authoring/LlmMarkdown/LlmMarkdownOutput.fs +++ b/tests/authoring/LlmMarkdown/LlmMarkdownOutput.fs @@ -445,7 +445,7 @@ type ``codeblock in list`` () = ``` """ -type ``substitions`` () = +type ``substitutions`` () = static let markdown = Setup.Document """--- sub: hello-world: "Hello World!" @@ -462,7 +462,7 @@ Hello, this is a substitution: Hello World! This is not a substitution: {{not-found}} """ -type ``substition in codeblock`` () = +type ``substitution in codeblock`` () = static let markdown = Setup.Document """--- sub: hello-world: "Hello World!" @@ -488,3 +488,18 @@ Hello, this is a substitution: {{hello-world}} Hello, this is a substitution: Hello World! ``` """ + +type ``substitution in heading`` () = + static let markdown = Setup.Document """--- +sub: + world: "World" +--- + +## Hello, {{world}}! +""" + + [] + let ``renders correctly`` () = + markdown |> convertsToNewLLM """ +## Hello, World! +"""