diff --git a/asciidoc/deployment/pom.xml b/asciidoc/deployment/pom.xml new file mode 100644 index 00000000..792aeb75 --- /dev/null +++ b/asciidoc/deployment/pom.xml @@ -0,0 +1,52 @@ + + + 4.0.0 + + + io.quarkiverse.qute.web + quarkus-qute-web-asciidoc-parent + 999-SNAPSHOT + + quarkus-qute-web-asciidoc-deployment + Quarkus Qute Web - Asciidoc - Deployment + + + + io.quarkiverse.qute.web + quarkus-qute-web-asciidoc + ${project.version} + + + io.quarkus + quarkus-junit5-internal + test + + + io.quarkus + quarkus-qute-deployment + + + org.assertj + assertj-core + ${assertj.version} + test + + + + + + + maven-compiler-plugin + + + + io.quarkus + quarkus-extension-processor + ${quarkus.version} + + + + + + + diff --git a/asciidoc/deployment/src/main/java/io/quarkiverse/qute/web/asciidoc/deployment/QuteWebAsciidocProcessor.java b/asciidoc/deployment/src/main/java/io/quarkiverse/qute/web/asciidoc/deployment/QuteWebAsciidocProcessor.java new file mode 100644 index 00000000..970f369a --- /dev/null +++ b/asciidoc/deployment/src/main/java/io/quarkiverse/qute/web/asciidoc/deployment/QuteWebAsciidocProcessor.java @@ -0,0 +1,22 @@ +package io.quarkiverse.qute.web.asciidoc.deployment; + +import io.quarkiverse.qute.web.asciidoc.runtime.AsciidocSectionHelperFactory; +import io.quarkus.arc.deployment.AdditionalBeanBuildItem; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +class QuteWebAsciidocProcessor { + + private static final String FEATURE = "qute-web-asciidoc"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + void process(BuildProducer additionalBeans) { + additionalBeans.produce(new AdditionalBeanBuildItem(AsciidocSectionHelperFactory.class)); + } +} diff --git a/asciidoc/deployment/src/test/java/io/quarkiverse/qute/web/asciidoc/test/QuarkusAsciidocTest.java b/asciidoc/deployment/src/test/java/io/quarkiverse/qute/web/asciidoc/test/QuarkusAsciidocTest.java new file mode 100644 index 00000000..28cb1332 --- /dev/null +++ b/asciidoc/deployment/src/test/java/io/quarkiverse/qute/web/asciidoc/test/QuarkusAsciidocTest.java @@ -0,0 +1,78 @@ +package io.quarkiverse.qute.web.asciidoc.test; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; + +import org.assertj.core.api.SoftAssertions; +import org.junit.jupiter.api.Test; + +import io.quarkiverse.qute.web.asciidoc.runtime.AsciidocSectionHelperFactory; +import io.quarkus.qute.Engine; + +public class QuarkusAsciidocTest { + + @Test + public void shouldConvertUsingAsciiTag() { + Engine engine = Engine.builder().addDefaults() + .addSectionHelper(new AsciidocSectionHelperFactory()).build(); + + String result = engine.parse("{#ascii}...{/ascii}").render(); + + assertThat(result).contains(""" +

+ ... +

+ """); + } + + @Test + public void shouldConvertUsingAsciidocTag() { + Engine engine = Engine.builder().addDefaults() + .addSectionHelper(new AsciidocSectionHelperFactory()).build(); + + String result = engine.parse("{#asciidoc}...{/asciidoc}").render(); + + assertThat(result).contains(""" +

+ ... +

+ """); + } + + @Test + public void testH1() { + Engine engine = Engine.builder().addDefaults() + .addSectionHelper(new AsciidocSectionHelperFactory()).build(); + + String result = engine.parse("{#ascii}= Quarkus and Roq{/ascii}").render(); + + assertThat(result).contains("

Quarkus and Roq

"); + } + + @Test + void shouldConvertWithForTagInsideAsciiTag() { + + Engine engine = Engine.builder().addDefaults() + .addSectionHelper(new AsciidocSectionHelperFactory()).build(); + + String result = engine.parse(""" +

Quarkus and Qute

+ {#ascii} + == Qute and Roq + Here is a list: + {#for item in items} + * an {item} as a list item + {/for} + {/ascii} + """).data("items", List.of("apple", "banana", "cherry")) + .render(); + + SoftAssertions.assertSoftly(softly -> { + softly.assertThat(result).contains("

Quarkus and Qute

"); + softly.assertThat(result).contains("

Qute and Roq

"); + softly.assertThat(result).contains("