Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish tab and tab-item #66

Merged
merged 2 commits into from
Nov 14, 2024
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");
}

}