Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -26,17 +24,26 @@ public int FindIndex()
public class TabItemBlock(DirectiveBlockParser parser, Dictionary<string, string> 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; }
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");
}

}