JAVA-29281 Create new module Text Processing Libraries Modules (#15479)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
## Asciidoctor
|
||||
|
||||
This module contains articles about Asciidoctor
|
||||
|
||||
### Relevant articles:
|
||||
|
||||
- [Generating a Book with Asciidoctor](https://www.baeldung.com/asciidoctor-book)
|
||||
- [Introduction to Asciidoctor in Java](https://www.baeldung.com/asciidoctor)
|
||||
@@ -0,0 +1,71 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>asciidoctor</artifactId>
|
||||
<name>asciidoctor</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>text-processing-libraries-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctorj</artifactId>
|
||||
<version>${asciidoctorj.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctorj-pdf</artifactId>
|
||||
<version>${asciidoctorj-pdf.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctor-maven-plugin</artifactId>
|
||||
<version>${asciidoctor-maven-plugin.version}</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.asciidoctor</groupId>
|
||||
<artifactId>asciidoctorj-pdf</artifactId>
|
||||
<version>${asciidoctorj-pdf.plugin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>output-pdf</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>process-asciidoc</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<sourceDirectory>src/docs/asciidoc</sourceDirectory>
|
||||
<outputDirectory>target/docs/asciidoc</outputDirectory>
|
||||
<attributes>
|
||||
<pdf-stylesdir>${project.basedir}/src/themes</pdf-stylesdir>
|
||||
<pdf-style>custom</pdf-style>
|
||||
</attributes>
|
||||
<backend>pdf</backend>
|
||||
<doctype>book</doctype>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<asciidoctor-maven-plugin.version>2.2.2</asciidoctor-maven-plugin.version>
|
||||
<asciidoctorj.version>2.5.7</asciidoctorj.version>
|
||||
<asciidoctorj-pdf.version>2.3.4</asciidoctorj-pdf.version>
|
||||
<asciidoctorj-pdf.plugin.version>2.3.4</asciidoctorj-pdf.plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
:icons: font
|
||||
|
||||
|
||||
= Generating book with AsciiDoctorj
|
||||
Baeldung
|
||||
|
||||
[abstract]
|
||||
This is the actual content.
|
||||
|
||||
== First Section
|
||||
|
||||
This is first section of the book where you can include some nice icons like icon:comment[].
|
||||
You can also create http://www.baeldung.com[links]
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.baeldung.asciidoctor;
|
||||
|
||||
import static org.asciidoctor.Asciidoctor.Factory.create;
|
||||
import static org.asciidoctor.OptionsBuilder.options;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.asciidoctor.Asciidoctor;
|
||||
|
||||
public class AsciidoctorDemo {
|
||||
|
||||
private final Asciidoctor asciidoctor;
|
||||
|
||||
AsciidoctorDemo() {
|
||||
asciidoctor = create();
|
||||
}
|
||||
|
||||
public void generatePDFFromString(final String input) {
|
||||
|
||||
final Map<String, Object> options = options().inPlace(true)
|
||||
.backend("pdf")
|
||||
.asMap();
|
||||
|
||||
|
||||
final String outfile = asciidoctor.convertFile(new File("sample.adoc"), options);
|
||||
}
|
||||
|
||||
String generateHTMLFromString(final String input) {
|
||||
return asciidoctor.convert("Hello _Baeldung_!", new HashMap<String, Object>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.asciidoctor;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AsciidoctorDemoIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void givenString_whenConverting_thenResultingHTMLCode() {
|
||||
final AsciidoctorDemo asciidoctorDemo = new AsciidoctorDemo();
|
||||
Assert.assertEquals(asciidoctorDemo.generateHTMLFromString("Hello _Baeldung_!"), "<div class=\"paragraph\">\n<p>Hello <em>Baeldung</em>!</p>\n</div>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
title_page:
|
||||
align: left
|
||||
|
||||
page:
|
||||
layout: portrait
|
||||
margin: [0.75in, 1in, 0.75in, 1in]
|
||||
size: A4
|
||||
base:
|
||||
font_color: #333333
|
||||
line_height_length: 17
|
||||
line_height: $base_line_height_length / $base_font_size
|
||||
link:
|
||||
font_color: #009900
|
||||
|
||||
header:
|
||||
height: 0.5in
|
||||
line_height: 1
|
||||
recto_content:
|
||||
center: '{document-title}'
|
||||
verso_content:
|
||||
center: '{document-title}'
|
||||
|
||||
footer:
|
||||
height: 0.5in
|
||||
line_height: 1
|
||||
recto_content:
|
||||
right: '{chapter-title} | *{page-number}*'
|
||||
verso_content:
|
||||
left: '*{page-number}* | {chapter-title}'
|
||||
Reference in New Issue
Block a user