Skip to content

Commit 3e37dc0

Browse files
committed
Clean up
1 parent a65dc71 commit 3e37dc0

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

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

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,26 @@ public class StepViewModel : DirectiveViewModel
2020
/// </summary>
2121
public HtmlString RenderTitle()
2222
{
23-
// Apply substitutions first, then parse with Markdig
23+
// Parse the title as markdown with full pipeline (including substitutions)
2424
var directiveBlock = (DirectiveBlock)DirectiveBlock;
25-
var span = Title.AsSpan();
26-
var processedTitle = span.ReplaceSubstitutions(directiveBlock.Build.Configuration.Substitutions, directiveBlock.Build.Collector, out var replacement)
27-
? replacement : Title;
25+
var context = new ParserContext(new ParserState(directiveBlock.Build)
26+
{
27+
MarkdownSourcePath = directiveBlock.CurrentFile,
28+
YamlFrontMatter = null,
29+
DocumentationFileLookup = (path) => null!,
30+
CrossLinkResolver = null!
31+
});
2832

29-
// Parse the processed title as markdown inline content
30-
var document = Markdig.Markdown.Parse(processedTitle, MarkdownParser.Pipeline);
33+
var document = Markdig.Markdown.Parse(Title, MarkdownParser.Pipeline, context);
3134

3235
if (document.FirstOrDefault() is not Markdig.Syntax.ParagraphBlock firstBlock)
33-
return new(processedTitle);
36+
return new(Title);
3437

3538
// Use the HTML renderer to render the inline content with full processing
3639
var subscription = DocumentationObjectPoolProvider.HtmlRendererPool.Get();
3740
_ = subscription.HtmlRenderer.WriteLeafInline(firstBlock);
3841

39-
var result = subscription.RentedStringBuilder?.ToString() ?? processedTitle;
42+
var result = subscription.RentedStringBuilder?.ToString() ?? Title;
4043
DocumentationObjectPoolProvider.HtmlRendererPool.Return(subscription);
4144
return new(result);
4245
}

0 commit comments

Comments
 (0)