Skip to content

Commit

Permalink
Finish tab and tab-item (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz authored Nov 14, 2024
1 parent 667b6d6 commit f5fc018
Showing 1 changed file with 14 additions and 7 deletions.
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");
}

}

0 comments on commit f5fc018

Please sign in to comment.