diff --git a/src/Elastic.Markdown/Myst/Directives/Admonition/AdmonitionBlock.cs b/src/Elastic.Markdown/Myst/Directives/Admonition/AdmonitionBlock.cs index 04c50ec60..ba676590f 100644 --- a/src/Elastic.Markdown/Myst/Directives/Admonition/AdmonitionBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/Admonition/AdmonitionBlock.cs @@ -8,7 +8,7 @@ namespace Elastic.Markdown.Myst.Directives.Admonition; public class DropdownBlock(DirectiveBlockParser parser, ParserContext context) : AdmonitionBlock(parser, "dropdown", context); -public class AdmonitionBlock : DirectiveBlock +public class AdmonitionBlock : DirectiveBlock, IBlockTitle { public AdmonitionBlock(DirectiveBlockParser parser, string admonition, ParserContext context) : base(parser, context) { @@ -45,5 +45,3 @@ public override void FinalizeAndValidate(ParserContext context) Title = Title.ReplaceSubstitutions(context); } } - - diff --git a/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs b/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs index f1e588d4e..4cda54a91 100644 --- a/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs @@ -13,6 +13,11 @@ namespace Elastic.Markdown.Myst.Directives; +public interface IBlockTitle +{ + string Title { get; } +} + public interface IBlockExtension : IBlock { BuildContext Build { get; } diff --git a/src/Elastic.Markdown/Myst/Directives/Stepper/StepperBlock.cs b/src/Elastic.Markdown/Myst/Directives/Stepper/StepperBlock.cs index a0ad9e509..4f8645ff0 100644 --- a/src/Elastic.Markdown/Myst/Directives/Stepper/StepperBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/Stepper/StepperBlock.cs @@ -16,7 +16,7 @@ public override void FinalizeAndValidate(ParserContext context) } } -public class StepBlock(DirectiveBlockParser parser, ParserContext context) : DirectiveBlock(parser, context) +public class StepBlock(DirectiveBlockParser parser, ParserContext context) : DirectiveBlock(parser, context), IBlockTitle { public override string Directive => "step"; public string Title { get; private set; } = string.Empty; diff --git a/src/Elastic.Markdown/Myst/Directives/Tabs/TabSetBlock.cs b/src/Elastic.Markdown/Myst/Directives/Tabs/TabSetBlock.cs index c491d4dff..e91744028 100644 --- a/src/Elastic.Markdown/Myst/Directives/Tabs/TabSetBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/Tabs/TabSetBlock.cs @@ -33,7 +33,7 @@ public int FindIndex() } public class TabItemBlock(DirectiveBlockParser parser, ParserContext context) - : DirectiveBlock(parser, context) + : DirectiveBlock(parser, context), IBlockTitle { public override string Directive => "tab-item"; diff --git a/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs b/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs index 2fca4e4b7..516f33a81 100644 --- a/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs +++ b/src/Elastic.Markdown/Myst/Renderers/LlmMarkdown/LlmBlockRenderers.cs @@ -8,7 +8,6 @@ using Elastic.Markdown.Myst.Directives.Admonition; using Elastic.Markdown.Myst.Directives.Image; using Elastic.Markdown.Myst.Directives.Include; -using Elastic.Markdown.Myst.Directives.Tabs; using Markdig.Extensions.DefinitionLists; using Markdig.Extensions.Tables; using Markdig.Extensions.Yaml; @@ -384,14 +383,13 @@ protected override void Write(LlmMarkdownRenderer renderer, DirectiveBlock obj) switch (obj) { - case DropdownBlock dropdown: - renderer.Writer.Write($" title=\"{dropdown.Title}\""); + case AdmonitionBlock when obj.Directive + is "note" or "tip" or "warning" or "important": + // skip for these directives + // otherwise it will render as break; - case TabItemBlock tabItem: - renderer.Writer.Write($" title=\"{tabItem.Title}\""); - break; - case AdmonitionBlock admonition when obj.Directive is "admonition": - renderer.Writer.Write($" title=\"{admonition.Title}\""); + case IBlockTitle titledBlock: + renderer.Writer.Write($" title=\"{titledBlock.Title}\""); break; }