Skip to content

Commit

Permalink
Introduce AsciidoctorJ
Browse files Browse the repository at this point in the history
Co-authored-by: jtama<[email protected]>
  • Loading branch information
ia3andy committed Dec 19, 2024
1 parent 711c7b1 commit 4e68aa3
Show file tree
Hide file tree
Showing 40 changed files with 969 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties


# Asciidoctor
.asciidoctor
52 changes: 52 additions & 0 deletions asciidoc/asciidoc-light/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc-light-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-qute-web-asciidoc-light-deployment</artifactId>
<name>Quarkus Qute Web - Asciidoc - Light - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc-light</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-qute-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.quarkiverse.qute.web.asciidoc.deployment;
package io.quarkiverse.qute.web.asciidoclight.deployment;

import java.util.ArrayList;
import java.util.List;

import io.quarkiverse.qute.web.asciidoc.runtime.AsciidocSectionHelperFactory;
import io.quarkiverse.qute.web.asciidoclight.runtime.AsciidocLightSectionHelperFactory;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
Expand All @@ -13,7 +13,7 @@

class QuteWebAsciidocProcessor {

private static final String FEATURE = "qute-web-asciidoc";
private static final String FEATURE = "qute-web-asciidoc-light";

@BuildStep
FeatureBuildItem feature() {
Expand All @@ -22,7 +22,7 @@ FeatureBuildItem feature() {

@BuildStep
void process(BuildProducer<AdditionalBeanBuildItem> additionalBeans) {
additionalBeans.produce(new AdditionalBeanBuildItem(AsciidocSectionHelperFactory.class));
additionalBeans.produce(new AdditionalBeanBuildItem(AsciidocLightSectionHelperFactory.class));
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.qute.web.asciidoc.test;
package io.quarkiverse.qute.web.asciidoclight.test;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -7,15 +7,15 @@
import org.assertj.core.api.SoftAssertions;
import org.junit.jupiter.api.Test;

import io.quarkiverse.qute.web.asciidoc.runtime.AsciidocSectionHelperFactory;
import io.quarkiverse.qute.web.asciidoclight.runtime.AsciidocLightSectionHelperFactory;
import io.quarkus.qute.Engine;

public class QuarkusAsciidocTest {
public class QuarkusAsciidocLightTest {

@Test
public void shouldConvertUsingAsciiTag() {
Engine engine = Engine.builder().addDefaults()
.addSectionHelper(new AsciidocSectionHelperFactory()).build();
.addSectionHelper(new AsciidocLightSectionHelperFactory()).build();

String result = engine.parse("{#ascii}...{/ascii}").render();

Expand All @@ -29,7 +29,7 @@ public void shouldConvertUsingAsciiTag() {
@Test
public void shouldConvertUsingAsciidocTag() {
Engine engine = Engine.builder().addDefaults()
.addSectionHelper(new AsciidocSectionHelperFactory()).build();
.addSectionHelper(new AsciidocLightSectionHelperFactory()).build();

String result = engine.parse("{#asciidoc}...{/asciidoc}").render();

Expand All @@ -43,7 +43,7 @@ public void shouldConvertUsingAsciidocTag() {
@Test
public void testH1() {
Engine engine = Engine.builder().addDefaults()
.addSectionHelper(new AsciidocSectionHelperFactory()).build();
.addSectionHelper(new AsciidocLightSectionHelperFactory()).build();

String result = engine.parse("{#ascii}= Quarkus and Roq{/ascii}").render();

Expand All @@ -54,7 +54,7 @@ public void testH1() {
void shouldConvertWithForTagInsideAsciiTag() {

Engine engine = Engine.builder().addDefaults()
.addSectionHelper(new AsciidocSectionHelperFactory()).build();
.addSectionHelper(new AsciidocLightSectionHelperFactory()).build();

String result = engine.parse("""
<h1>Quarkus and Qute</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.qute.web.asciidoc.test;
package io.quarkiverse.qute.web.asciidoclight.test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.qute.web.asciidoc.test;
package io.quarkiverse.qute.web.asciidoclight.test;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.qute.web.asciidoc.test;
package io.quarkiverse.qute.web.asciidoclight.test;

import jakarta.inject.Inject;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc-parent</artifactId>
<artifactId>quarkus-qute-web-asciidoc-light-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-qute-web-asciidoc-integration-tests</artifactId>
<name>Quarkus Qute Web - AsciiDoc - Integration Tests</name>
<artifactId>quarkus-qute-web-asciidoc-light-integration-tests</artifactId>
<name>Quarkus Qute Web - AsciiDoc - Light - Integration Tests</name>
<properties>
<skipITs>true</skipITs>
</properties>
Expand All @@ -19,7 +19,7 @@
</dependency>
<dependency>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc</artifactId>
<artifactId>quarkus-qute-web-asciidoc-light</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkiverse.qute.web.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class QuteWebAsciidocLightIT extends QuteWebAsciidocLightTest {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class QuteWebAsciiDocTest {
public class QuteWebAsciidocLightTest {

@Test
public void testTemplates() {
Expand Down
35 changes: 35 additions & 0 deletions asciidoc/asciidoc-light/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>quarkus-qute-web-asciidoc-light-parent</artifactId>
<version>999-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Quarkus Qute Web - Asciidoc - Light - Parent</name>

<modules>
<module>deployment</module>
<module>runtime</module>
</modules>
<profiles>
<profile>
<id>it</id>
<activation>
<property>
<name>performRelease</name>
<value>!true</value>
</property>
</activation>
<modules>
<module>integration-tests</module>
</modules>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

<parent>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc-parent</artifactId>
<artifactId>quarkus-qute-web-asciidoc-light-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-qute-web-asciidoc</artifactId>
<name>Quarkus Qute - Asciidoc - Runtime</name>
<artifactId>quarkus-qute-web-asciidoc-light</artifactId>
<name>Quarkus Qute - Asciidoc - Light - Runtime</name>

<dependencies>
<dependency>
Expand All @@ -18,12 +18,12 @@
<dependency>
<groupId>io.yupiik.maven</groupId>
<artifactId>asciidoc-java</artifactId>
<version>${asciidoc.java.version}</version>
<version>${asciidoc.light.version}</version>
</dependency>
<dependency>
<groupId>io.yupiik.maven</groupId>
<artifactId>ascii2svg</artifactId>
<version>${asciidoc.java.version}</version>
<version>${asciidoc.light.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkiverse.qute.web.asciidoc.runtime;
package io.quarkiverse.qute.web.asciidoclight.runtime;

import java.nio.file.Path;
import java.util.Map;
Expand All @@ -8,7 +8,7 @@
import io.yupiik.asciidoc.parser.resolver.ContentResolver;
import io.yupiik.asciidoc.renderer.html.AsciidoctorLikeHtmlRenderer;

public class AsciidocConverter {
public class AsciidocLightConverter {

private final Parser parser = new Parser();
private final AsciidoctorLikeHtmlRenderer.Configuration config = new AsciidoctorLikeHtmlRenderer.Configuration()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package io.quarkiverse.qute.web.asciidoc.runtime;
package io.quarkiverse.qute.web.asciidoclight.runtime;

import java.util.List;
import java.util.concurrent.CompletionStage;

import io.quarkus.qute.CompletedStage;
import io.quarkus.qute.EngineConfiguration;
import io.quarkus.qute.RawString;
import io.quarkus.qute.ResultNode;
import io.quarkus.qute.SectionHelper;
import io.quarkus.qute.SectionHelperFactory;
import io.quarkus.qute.SingleResultNode;
import io.quarkus.qute.TemplateExtension;

@EngineConfiguration
public class AsciidocSectionHelperFactory
implements SectionHelperFactory<AsciidocSectionHelperFactory.AsciidocSectionHelper> {
public class AsciidocLightSectionHelperFactory
implements SectionHelperFactory<AsciidocLightSectionHelperFactory.AsciidocSectionHelper> {

private static final AsciidocConverter CONVERTER = new AsciidocConverter();
private static final AsciidocLightConverter CONVERTER = new AsciidocLightConverter();
private static final AsciidocSectionHelper HELPER = new AsciidocSectionHelper();

@Override
Expand All @@ -29,8 +30,8 @@ public AsciidocSectionHelper initialize(SectionInitContext context) {
}

@TemplateExtension(matchNames = { "asciidocify", "asciidocToHtml" })
static String convertToAsciidoc(String text, String ignoredName) {
return CONVERTER.apply(text);
static RawString convertToAsciidoc(String text, String ignoredName) {
return new RawString(CONVERTER.apply(text));
}

public static class AsciidocSectionHelper implements SectionHelper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Qute Web Asciidoc
description: A Qute Web extension designed to simplify the conversion of AsciiDoc to HTML by providing a set of AsciiDoc tags.
name: Qute Web Asciidoc Light
description: A Qute Web extension designed to simplify the conversion of AsciiDoc to HTML by providing a set of AsciiDoc tags using a light pure Java converter. It's faster but it is not feature complete.
metadata:
keywords:
- qute-web-asciidoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

<parent>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc-parent</artifactId>
<artifactId>quarkus-qute-web-asciidoctorj-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-qute-web-asciidoc-deployment</artifactId>
<name>Quarkus Qute Web - Asciidoc - Deployment</name>
<artifactId>quarkus-qute-web-asciidoctorj-deployment</artifactId>
<name>Quarkus Qute Web - AsciidoctorJ - Deployment</name>

<dependencies>
<dependency>
<groupId>io.quarkiverse.qute.web</groupId>
<artifactId>quarkus-qute-web-asciidoc</artifactId>
<artifactId>quarkus-qute-web-asciidoctorj</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.quarkiverse.qute.web.asciidoctorj.deployment;

import io.quarkiverse.qute.web.asciidoctorj.runtime.AsciidoctorJConfig;
import io.quarkiverse.qute.web.asciidoctorj.runtime.AsciidoctorJConverter;
import io.quarkiverse.qute.web.asciidoctorj.runtime.AsciidoctorJSectionHelperFactory;
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 QuteWebAsciidoctorJProcessor {

private static final String FEATURE = "qute-web-asciidoctorj";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
void process(BuildProducer<AdditionalBeanBuildItem> additionalBeans, AsciidoctorJConfig config) {
additionalBeans.produce(new AdditionalBeanBuildItem(AsciidoctorJSectionHelperFactory.class));
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(AsciidoctorJConverter.class));
}

}
Loading

0 comments on commit 4e68aa3

Please sign in to comment.