generate pdf with extensions through asciidoctorj

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

generate pdf with extensions through asciidoctorj

Hi everyone,
I am not sure if I am getting the documentation right, but I should be able to compile a document I am able to compile with asciidoctor-pdf + extensions also with asciidoctorj, right?

I have tried several approaches and am not getting anywhere, maybe someone can hep me out. This is my last one:
String path = "/var/lib/gems/2.3.0:/home/asdasd/.gem/ruby/2.3.0:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.3.0:/usr/share/rubygems-integration/2.3.0:/usr/share/rubygems-integration/all";

Asciidoctor asciidoctor = create(path);

Ruby ruby = org.asciidoctor.internal.JRubyRuntimeContext.get();
InputStream libStream = new FileInputStream(new File("/path/to/asciidoctor-extensions-lab/lib/tree-block-macro/extension.rb"));
RubyUtils.loadRubyClass(Ruby.getGlobalRuntime(), libStream);
RubyUtils.requireLibrary(ruby, "asciidoctor-diagram");

Map<String, Object> opts = new HashMap<String, Object>();
opts.put("backend", "pdf");
opts.put("in_place", true);
asciidoctor.convertFile(new File("index.adoc"), opts);

What I am getting is an exception like:
Exception in thread "main" org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- thread_safe/jruby_cache_backend
	at RUBY.ThreadSafe(/var/lib/gems/2.3.0/gems/thread_safe-0.3.6/lib/thread_safe/cache.rb:12)

The file exists, so I am guessing that there is a problem mixing classpaths and versions that come from the OS installation:

Asciidoctor PDF 1.5.0.alpha.15 using Asciidoctor 1.5.5 []
Runtime Environment (ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)

and those packages that come with the maven installation of asciidoctorj (1.5.4).

So finally my questions:
* is my java Syntax for adding extensions from filesystem and gems right?
* is there a clean way I can proceed to do what I am trying to?

Thanks for any hint,