asciidoctorj
asciidoctorj copied to clipboard
Method convertDirectory does not return the names of the created files
I have followed the README file to create a small Java test program with asciidoctorj 1.5.4 (running JDK 1.8 on Windows 10). According to the README and the javadoc the method convertDirectory
should return the created files. But the returned array is empty.
Here is my code:
import static org.asciidoctor.Asciidoctor.Factory.create;
import static org.asciidoctor.AttributesBuilder.attributes;
import static org.asciidoctor.OptionsBuilder.options;
import java.util.Map;
import org.asciidoctor.AsciiDocDirectoryWalker;
import org.asciidoctor.Asciidoctor;
public class ConvertTest
{
public static void main(final String[] args)
{
Asciidoctor asciidoctor = create();
Map<String, Object> attributes = attributes().backend("html").asMap();
Map<String, Object> options = options().inPlace(false).attributes(attributes).asMap();
String[] result = asciidoctor.convertDirectory(
new AsciiDocDirectoryWalker("E:/Develop/asciidoc/ws/de.brisoft.asciidoc/TestFiles"), options);
System.out.println("Created files:");
for (String html : result)
{
System.out.println(html);
}
System.out.println("finished");
}
}
And this is the output:
Created files:
finished
You need to set the option toFile(false)
to get the content as String.
However, as you say I think the README is wrong, it does mention the need for toFile(false)
but only for convertFile and convertFiles. And below, the convertDirectory
example implies that by default the method returns String.
I have to admit that I only read the Java example code and not the whole explanation ... In the examples there is no call to toFile(false
but the returned Strings are printed. This is a bit confusing. I think it would help if the example code also contains this method call.