Skip to content

Commit 614082b

Browse files
committed
Update parsing of :open: on admonitions to be nullable
1 parent 00532cc commit 614082b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/Elastic.Markdown/Myst/Directives/AdmonitionBlock.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public string Title
3434
public override void FinalizeAndValidate(ParserContext context)
3535
{
3636
CrossReferenceName = Properties.GetValueOrDefault("name");
37-
DropdownOpen = PropBool("open");
37+
DropdownOpen = TryPropBool("open");
3838
if (DropdownOpen.HasValue)
3939
Classes = "dropdown";
4040
}

src/Elastic.Markdown/Myst/Directives/DirectiveBlock.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,16 @@ protected bool PropBool(params string[] keys)
9393
return bool.TryParse(value, out var result) && result;
9494
}
9595

96+
protected bool? TryPropBool(params string[] keys)
97+
{
98+
var value = Prop(keys);
99+
if (string.IsNullOrEmpty(value))
100+
return keys.Any(k => Properties.ContainsKey(k)) ? true : null;
101+
102+
return bool.TryParse(value, out var result) ? result : null;
103+
}
104+
105+
96106
protected string? Prop(params string[] keys)
97107
{
98108
foreach (var key in keys)

0 commit comments

Comments
 (0)