Skip to content

Commit 481bf2e

Browse files
committed
Fix nested directives within a list
1 parent f2af906 commit 481bf2e

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ public override BlockState TryContinue(BlockProcessor processor, Block block)
172172
if (block is not DirectiveBlock directiveBlock)
173173
return base.TryContinue(processor, block);
174174

175+
if (line.StartsWith(":::"))
176+
return base.TryContinue(processor, block);
177+
175178
var tokens = line.ToString().Split(':', 3, RemoveEmptyEntries | TrimEntries);
176179
if (tokens.Length < 1)
177180
return base.TryContinue(processor, block);

tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,89 @@ A regular paragraph.
9999
[Fact]
100100
public void SetsDropdownOpen() => Block!.DropdownOpen.Should().BeTrue();
101101
}
102+
103+
104+
public class NestedDirectiveWithListTests(ITestOutputHelper output) : DirectiveTest<AdmonitionBlock>(output,
105+
"""
106+
# heading
107+
108+
:::::{note}
109+
110+
- List Item 1
111+
::::{note}
112+
Hello, World!
113+
::::
114+
115+
## What
116+
117+
:::::
118+
"""
119+
)
120+
{
121+
[Fact]
122+
public void Render() => Html.Should().Contain("""
123+
<li> List Item 1
124+
<div class="admonition note">
125+
<p class="admonition-title">Note</p>
126+
Hello, World!
127+
</div>
128+
</li>
129+
""");
130+
}
131+
132+
133+
public class NestedDirectiveWithListTests2(ITestOutputHelper output) : DirectiveTest<AdmonitionBlock>(output,
134+
"""
135+
# heading
136+
137+
:::{note}
138+
139+
- List Item 1
140+
:::{note}
141+
Hello, World!
142+
:::
143+
144+
## What
145+
146+
:::
147+
"""
148+
)
149+
{
150+
[Fact]
151+
public void Render() => Html.Should().Contain("""
152+
<li> List Item 1
153+
<div class="admonition note">
154+
<p class="admonition-title">Note</p>
155+
Hello, World!
156+
</div>
157+
</li>
158+
""");
159+
}
160+
161+
public class NestedDirectiveWithListTests3(ITestOutputHelper output) : DirectiveTest<AdmonitionBlock>(output,
162+
"""
163+
# heading
164+
165+
:::{note}
166+
167+
- List Item 1
168+
:::::{note}
169+
Hello, World!
170+
:::::
171+
172+
## What
173+
174+
:::
175+
"""
176+
)
177+
{
178+
[Fact]
179+
public void Render() => Html.Should().Contain("""
180+
<li> List Item 1
181+
<div class="admonition note">
182+
<p class="admonition-title">Note</p>
183+
Hello, World!
184+
</div>
185+
</li>
186+
""");
187+
}

0 commit comments

Comments
 (0)