File tree Expand file tree Collapse file tree
main/java/com/baeldung/asciidoctor
test/java/com/baeldung/asciidoctor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 180180 <artifactId >serenity-core</artifactId >
181181 <version >${serenity.version} </version >
182182 <scope >test</scope >
183+ <exclusions >
184+ <exclusion >
185+ <groupId >org.asciidoctor</groupId >
186+ <artifactId >asciidoctor-java-integration</artifactId >
187+ </exclusion >
188+ </exclusions >
183189 </dependency >
184190 <dependency >
185191 <groupId >net.serenity-bdd</groupId >
323329 <artifactId >netty-all</artifactId >
324330 <version >${netty.version} </version >
325331 </dependency >
332+ <dependency >
333+ <groupId >org.asciidoctor</groupId >
334+ <artifactId >asciidoctorj</artifactId >
335+ <version >1.5.4</version >
336+ </dependency >
337+ <dependency >
338+ <groupId >org.asciidoctor</groupId >
339+ <artifactId >asciidoctorj-pdf</artifactId >
340+ <version >1.5.0-alpha.11</version >
341+ </dependency >
326342 <!-- OpenNLP -->
327343 <dependency >
328344 <groupId >org.apache.opennlp</groupId >
Original file line number Diff line number Diff line change 1+ package com .baeldung .asciidoctor ;
2+
3+ import static org .asciidoctor .Asciidoctor .Factory .create ;
4+ import static org .asciidoctor .OptionsBuilder .options ;
5+
6+ import java .io .File ;
7+ import java .util .HashMap ;
8+ import java .util .Map ;
9+
10+ import org .asciidoctor .Asciidoctor ;
11+
12+ public class AsciidoctorDemo {
13+
14+ private final Asciidoctor asciidoctor ;
15+
16+ public AsciidoctorDemo () {
17+ asciidoctor = create ();
18+ }
19+
20+ public void generatePDFFromString (final String input ) {
21+
22+ final Map <String , Object > options = options ().inPlace (true )
23+ .backend ("pdf" )
24+ .asMap ();
25+
26+ final String outfile = asciidoctor .convertFile (new File ("sample.adoc" ), options );
27+ }
28+
29+ public String generateHTMLFromString (final String input ) {
30+ final String output = asciidoctor .convert ("Hello _Baeldung_!" , new HashMap <String , Object >());
31+ return output ;
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package com .baeldung .asciidoctor ;
2+
3+ import org .junit .Assert ;
4+ import org .junit .Test ;
5+
6+ public class AsciidoctorDemoTest {
7+
8+ @ Test
9+ public void givenString_whenConverting_thenResultingHTMLCode () {
10+ final AsciidoctorDemo asciidoctorDemo = new AsciidoctorDemo ();
11+ Assert .assertEquals (asciidoctorDemo .generateHTMLFromString ("Hello _Baeldung_!" ), "<div class=\" paragraph\" >\n <p>Hello <em>Baeldung</em>!</p>\n </div>" );
12+ }
13+ }
You can’t perform that action at this time.
0 commit comments