Open mcruzdev opened 1 week ago
Hi @ia3andy, this is the first draft, to see if I am on the right path
This looks good right @mkouba ?
Could you add this test:
<h1>some html</h2>
{#md}
# Hello markdown
Here is a list:
{#for item in items}
* an {item} as a list
{/for}
<a href="/path">some {html} in the markdown</a>
{/md}
Could you add this test:
<h1>some html</h2> {#md} # Hello markdown Here is a list: {#for item in items} * an {item} as a list {/for} <a href="/path">some {html} in the markdown</a> {/md}
Probably this one will fail 😆
Thank you for all your comments, I will take a look here
Hi @mkouba and @ia3andy, actually when we are using this one:
<h1>Quarkus and Qute</h1>
{#md}
# Qute and Roq
Here is a list:
{#for item in items}
- an {item} as a list item
{/for}
{/md}
We are getting:
<h1>Quarkus and Qute</h1>
<h1>Qute and Roq</h1>
<p>Here is a list:</p>
<ul>
<li>an</li>
</ul>
<p>apple</p>
<p>as a list item</p>
<ul>
<li>an</li>
</ul>
<p>banana</p>
<p>as a list item</p>
<ul>
<li>an</li>
</ul>
<p>cherry</p>
<p>as a list item</p>
I think that the expected behavior is:
{#for}
(more specific section); {#md}
with {#for}
result;In other words, resolve all sections inside the markdown first. I am new to qute API, do you know how to solve this one?
In other words, resolve all sections inside the markdown first. I am new to qute API, do you know how to solve this one?
@mcruzdev Your code looks good. I think there's some problem with line separators or something like that. What does the content passed to the MarkdownConverter
look like?
Ah, I see where the problem is. You need to first collect all the results and then apply the converter:
public CompletionStage<ResultNode> resolve(SectionResolutionContext context) {
return context.execute().thenCompose(rn -> {
StringBuilder sb = new StringBuilder();
rn.process(sb::append);
return CompletedStage.of(new SingleResultNode(markdownConverter.convert(sb.toString())));
});
}
By the way, you don't need a QuarkusUnitTest
to test the functionality of the section itself. A simple unit test would be enough:
public class MdTest {
@Test
public void testMd() {
Engine engine = Engine.builder().addDefaults()
.addSectionHelper(new MarkdownSectionHelper.Factory(new CommonMarkConverter())).build();
assertEquals("...", engine.parse("{#md}...{/md}").data("items", List.of("apple", "pie")).render());
}
}
@mkouba good?
@mcruzdev Could you pls squash the commits? I'll merge the PR afterwards...
Fixes #91