diff --git a/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs b/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs index 45358b18a..22ad8b4ec 100644 --- a/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs +++ b/src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs @@ -169,6 +169,9 @@ public override BlockState TryContinue(BlockProcessor processor, Block block) if (!line.StartsWith(":")) return base.TryContinue(processor, block); + if (line.StartsWith(":::")) + return base.TryContinue(processor, block); + if (block is not DirectiveBlock directiveBlock) return base.TryContinue(processor, block); diff --git a/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs b/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs index a0bc4bd87..0f6871ca0 100644 --- a/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/AdmonitionTests.cs @@ -99,3 +99,115 @@ A regular paragraph. [Fact] public void SetsDropdownOpen() => Block!.DropdownOpen.Should().BeTrue(); } + + +public class NestedDirectiveWithListTests(ITestOutputHelper output) : DirectiveTest(output, + """ + # heading + + :::::{note} + + - List Item 1 + ::::{note} + Hello, World! + :::: + + ## What + + ::::: + """ +) +{ + [Fact] + public void Render() => Html.Should().Contain(""" +
  • List Item 1 +
    +

    Note

    + Hello, World! +
    +
  • + """); +} + + +public class NestedDirectiveWithListTests2(ITestOutputHelper output) : DirectiveTest(output, + """ + # heading + + :::{note} + + - List Item 1 + :::{note} + Hello, World! + ::: + + ## What + + ::: + """ +) +{ + [Fact] + public void Render() => Html.Should().Contain(""" +
  • List Item 1 +
    +

    Note

    + Hello, World! +
    +
  • + """); +} + +public class NestedDirectiveWithListTests3(ITestOutputHelper output) : DirectiveTest(output, + """ + # heading + + :::{note} + + - List Item 1 + :::::{note} + Hello, World! + ::::: + + ## What + + ::: + """ +) +{ + [Fact] + public void Render() => Html.Should().Contain(""" +
  • List Item 1 +
    +

    Note

    + Hello, World! +
    +
  • + """); +} + + +public class DirectiveInList(ITestOutputHelper output) : DirectiveTest(output, + """ + # heading + + - List Item 1 + :::::{note} + Hello, World! + ::::: + """ +) +{ + [Fact] + public void Type() => Block!.Admonition.Should().Be("note"); + + [Fact] + public void Render() => Html.Should().Contain(""" +
  • List Item 1 +
    +

    Note

    + Hello, World! +
    +
  • + """); +} diff --git a/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs b/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs index 1a5856d23..1594cd966 100644 --- a/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs +++ b/tests/Elastic.Markdown.Tests/Directives/DirectiveBaseTests.cs @@ -23,8 +23,7 @@ public override async Task InitializeAsync() { await base.InitializeAsync(); Block = Document - .Where(block => block is TDirective) - .Cast() + .Descendants() .FirstOrDefault(); }