Re: Finally, a draft of the Asciidoctor extension API has landed!
Posted by asotobu on Aug 20, 2013; 7:51pm
URL: https://discuss.asciidoctor.org/Finally-a-draft-of-the-Asciidoctor-extension-API-has-landed-tp455p487.html
Dan I have just coded a first draft of extensions for AJI but I have some questions or a behavior which I am not pretty sure it is normal, let me show in code, maybe you find exactly the problem:
I have created a method which acts as a proxy to a Ruby class (the Asciidoctor Java class):
```ruby
require 'java'
require 'asciidoctor/extensions'
// some code for rendering documents
def preprocessor(processor)
puts processor
Asciidoctor::Extensions.register do |document|
puts "Hi"
preprocessor processor
end
end
```
'processor' is a java.lang.String which in fact would be the full qualified name of the extension, for example: org.asciidoctor.extensions.SamplePreprocessor
The problem is that when I execute the preprocessor method, the first puts prints the full qualified name of the class, but the puts "Hi" is never shown. I could understand that the String that is send to Asciidoctor is not treated correctly and we should think other possibilities (this is not a problem), but maybe I am doing something wrong?
Of course this is a test that will be refactored to an ExtensionRegistry class.