Skip to content

Commit

Permalink
Merge pull request #8 from pepijnve/patch-1
Browse files Browse the repository at this point in the history
Update to asciidoctor-diagram 2.0.5
  • Loading branch information
robertpanzer authored Oct 2, 2020
2 parents b38c834 + b628b6f commit 43dddc4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion asciidoctorj-diagram/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
properName=AsciidoctorJ Diagram
description=AsciidoctorJ Diagram bundles the Asciidoctor Diagram RubyGem (asciidoctor-diagram) so it can be loaded into the JVM using JRuby.
version=2.0.4
version=2.0.5
gem_name=asciidoctor-diagram
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ public class WhenDocumentContainsDitaaDiagram {
@Test
public void png_should_be_rendered_for_diagram() {

File inputFile = new File("build/resources/test/sample.adoc");
File outputDir = new File("build");
File outputFile1 = new File(outputDir, "asciidoctor-diagram-process.png");
File outputFile2 = new File(outputDir, ".asciidoctor/diagram/asciidoctor-diagram-process.png.cache");
File buildDir = new File("build/resources/test");

File inputFile = new File(buildDir, "sample.adoc");
File outputFile1 = new File(inputFile.getParentFile(), "asciidoctor-diagram-process.png");
File outputFile2 = new File(inputFile.getParentFile(), ".asciidoctor/diagram/asciidoctor-diagram-process.png.cache");
asciidoctor.requireLibrary("asciidoctor-diagram");
asciidoctor.convertFile(inputFile,
options()
.backend("html5")
.toDir(outputDir)
.safe(SafeMode.UNSAFE)
.toFile(new File(buildDir, "sample.html"))
.get());
assertThat(outputFile1.exists(), is(true));
assertThat(outputFile2.exists(), is(true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

import static org.asciidoctor.OptionsBuilder.options;
import static org.hamcrest.CoreMatchers.is;
Expand All @@ -18,23 +21,25 @@ public class WhenDocumentWantsDataUris {
private Asciidoctor asciidoctor = Asciidoctor.Factory.create();

@Test
public void png_should_be_rendered_for_diagram() {
public void png_should_be_rendered_for_diagram() throws IOException {
File buildDir = new File("build/resources/test");

File inputFile = new File("build/resources/test/data-uri.adoc");
File inputFile = new File(buildDir, "data-uri.adoc");
File outputFile = new File(buildDir, "data-uri.html");
File outputFile1 = new File(inputFile.getParentFile(), "data-uri-test.png");
File outputFile2 = new File(inputFile.getParentFile(), ".asciidoctor/diagram/data-uri-test.png.cache");
asciidoctor.requireLibrary("asciidoctor-diagram");
final String html = asciidoctor.convertFile(inputFile,
asciidoctor.convertFile(inputFile,
options().backend("html5")
.toFile(false)
.toDir(new File("build"))
.toFile(outputFile)
.safe(SafeMode.SERVER)
.get());
assertThat(outputFile1.exists(), is(true));
assertThat(outputFile2.exists(), is(true));
outputFile1.delete();
outputFile2.delete();

String html = new String(Files.readAllBytes(outputFile.toPath()), StandardCharsets.UTF_8);
final Document doc = Jsoup.parse(html);
System.out.println(doc);
Elements images = doc.getElementsByTag("img");
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2.0.4
version=2.0.5

0 comments on commit 43dddc4

Please sign in to comment.