Skip to content

Commit 31e6d29

Browse files
committed
Proper renderer
1 parent 055f622 commit 31e6d29

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/Elastic.Markdown/Myst/Directives/Stepper/StepViewModel.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,22 @@ public class StepViewModel : DirectiveViewModel
1818
/// <summary>
1919
/// Renders the title with full markdown processing (substitutions, links, emphasis, etc.)
2020
/// </summary>
21-
public HtmlString RenderTitle() =>
22-
// For now, just return the title as-is since substitutions are already applied in FinalizeAndValidate
23-
// In the future, this could be extended to handle full markdown processing using the HTML renderer
24-
new(Title);
21+
public HtmlString RenderTitle()
22+
{
23+
// Parse the title as markdown inline content
24+
var document = Markdig.Markdown.Parse(Title, MarkdownParser.Pipeline);
25+
var firstBlock = document.FirstOrDefault() as Markdig.Syntax.ParagraphBlock;
26+
var inline = firstBlock?.Inline;
27+
28+
if (firstBlock == null)
29+
return new(Title);
30+
31+
// Use the HTML renderer to render the inline content with full processing
32+
var subscription = DocumentationObjectPoolProvider.HtmlRendererPool.Get();
33+
_ = subscription.HtmlRenderer.WriteLeafInline(firstBlock);
34+
35+
var result = subscription.RentedStringBuilder?.ToString() ?? Title;
36+
DocumentationObjectPoolProvider.HtmlRendererPool.Return(subscription);
37+
return new(result);
38+
}
2539
}

0 commit comments

Comments
 (0)