From b33c95c109e4465d33d38ee223f20681519b7434 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Thu, 14 Nov 2024 09:42:06 +0100 Subject: [PATCH 1/2] tab-set-item => tab-item --- src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs b/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs index 0dceaf5..3fe94f5 100644 --- a/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs @@ -1,8 +1,6 @@ // Licensed to Elasticsearch B.V under one or more agreements. // Elasticsearch B.V licenses this file to you under the Apache 2.0 License. // See the LICENSE file in the project root for more information -using System.Xml; -using System.Xml.Xsl; namespace Elastic.Markdown.Myst.Directives; @@ -26,7 +24,7 @@ public int FindIndex() public class TabItemBlock(DirectiveBlockParser parser, Dictionary properties) : DirectiveBlock(parser, properties) { - public override string Directive => "tab-set-item"; + public override string Directive => "tab-item"; public string Title { get; set; } = default!; public int Index { get; set; } From 337f72a1e8a5e4f4dfd4e03a8d647080054e918b Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Thu, 14 Nov 2024 09:48:34 +0100 Subject: [PATCH 2/2] Add tab-item properties and validation --- .../Myst/Directives/TabSetBlock.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs b/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs index 3fe94f5..b5dbe9c 100644 --- a/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs +++ b/src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs @@ -26,15 +26,24 @@ public class TabItemBlock(DirectiveBlockParser parser, Dictionary "tab-item"; - public string Title { get; set; } = default!; - public int Index { get; set; } - public int TabSetIndex { get; set; } + public string Title { get; private set; } = default!; + public int Index { get; private set; } + public int TabSetIndex { get; private set; } + + public string? SyncKey { get; private set; } + public bool Selected { get; private set; } public override void FinalizeAndValidate(ParserContext context) { - Title = Arguments ?? "Unnamed Tab"; + if (string.IsNullOrWhiteSpace(Arguments)) + EmitError(context, "{tab-item} requires an argument to name the tab."); + + Title = Arguments ?? "{undefined}"; Index = Parent!.IndexOf(this); TabSetIndex = Parent is TabSetBlock tb ? tb.FindIndex() : -1; + + SyncKey = Prop("sync"); + Selected = PropBool("selected"); } }