Skip to content

Instantly share code, notes, and snippets.

@bclozel
Last active May 8, 2016 19:51
Show Gist options
  • Save bclozel/9efef280e8ac43f222f28deabea517a1 to your computer and use it in GitHub Desktop.
Save bclozel/9efef280e8ac43f222f28deabea517a1 to your computer and use it in GitHub Desktop.
import org.asciidoctor.Asciidoctor;
import org.asciidoctor.Attributes;
import org.asciidoctor.OptionsBuilder;
import org.asciidoctor.SafeMode;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class IncludeUrlsTests {
@Test
public void includeUrls() throws Exception {
String testDoc = "== Example Title\n" +
"\n" +
"include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/prereq_editor_jdk_buildtools.adoc[]";
Asciidoctor engine = Asciidoctor.Factory.create();
Attributes attributes = new Attributes();
attributes.setAllowUriRead(true);
String doc = engine.convert(testDoc, OptionsBuilder.options().safe(SafeMode.UNSAFE).attributes(attributes));
assertThat(doc).contains("Example Title").contains("JDK");
}
}
<?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>
<groupId>org.asciidoctorj.issues</groupId>
<artifactId>asciidoctorj-includeurls</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- Works with 1.5.3
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>1.5.3</version>
</dependency>
-->
<!-- Fails with 1.5.4 -->
<dependency>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctorj</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment