Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to asciidoctor-diagram 2.0.5 #8

Merged
merged 3 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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