Skip to content

Commit c312109

Browse files
committed
Add subs to stepper headings
1 parent ad418ac commit c312109

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/Elastic.Markdown/IO/MarkdownFile.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,25 @@ public static List<PageTocItem> GetAnchors(
289289
.OfType<StepBlock>()
290290
.Where(step => !string.IsNullOrEmpty(step.Title))
291291
.Where(step => !IsNestedInOtherDirective(step))
292-
.Select(step => new
292+
.Select(step =>
293293
{
294-
TocItem = new PageTocItem
294+
var processedTitle = step.Title;
295+
// Apply substitutions to step titles
296+
if (subs.Count > 0 && processedTitle.AsSpan().ReplaceSubstitutions(subs, set.Context.Collector, out var replacement))
295297
{
296-
Heading = step.Title,
297-
Slug = step.Anchor,
298-
Level = step.HeadingLevel // Use dynamic heading level
299-
},
300-
step.Line
298+
processedTitle = replacement;
299+
}
300+
301+
return new
302+
{
303+
TocItem = new PageTocItem
304+
{
305+
Heading = processedTitle,
306+
Slug = step.Anchor,
307+
Level = step.HeadingLevel // Use dynamic heading level
308+
},
309+
step.Line
310+
};
301311
});
302312

303313
var toc = headingTocs

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public class StepBlock(DirectiveBlockParser parser, ParserContext context) : Dir
2626
public override void FinalizeAndValidate(ParserContext context)
2727
{
2828
Title = Arguments ?? string.Empty;
29+
30+
// Apply substitutions to the title
31+
Title = Title.ReplaceSubstitutions(context);
32+
2933
Anchor = Prop("anchor") ?? Title.Slugify();
3034

3135
// Calculate heading level based on preceding heading

0 commit comments

Comments
 (0)