Login  Register

all.adoc: Failed to load AsciiDoc document - undefined method `document' for #<Asciidoctor::PreprocessorReader:0x1f9a7684>

Posted by ch007m on Apr 09, 2020; 5:08pm
URL: https://discuss.asciidoctor.org/all-adoc-Failed-to-load-AsciiDoc-document-undefined-method-document-for-Asciidoctor-PreprocessorRead-tp7873.html

Hi

Why the following asciidoctorj java code when it includes a preprocessor extension generates the following error ?

Apr 09, 2020 7:07:38 PM org.asciidoctor.jruby.internal.JRubyAsciidoctor convertFile
SEVERE: (NoMethodError) asciidoctor: FAILED: /Users/dabou/Code/github/cmoulliard/playbook-doc/asciidoctor/all.adoc: Failed to load AsciiDoc document - undefined method `document' for #<Asciidoctor::PreprocessorReader:0x69d2e517>
Exception in thread "main" org.asciidoctor.jruby.internal.AsciidoctorCoreException: org.jruby.exceptions.NoMethodError: (NoMethodError) asciidoctor: FAILED: /Users/dabou/Code/github/cmoulliard/playbook-doc/asciidoctor/all.adoc: Failed to load AsciiDoc document - undefined method `document' for #<Asciidoctor::PreprocessorReader:0x69d2e517>
        at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convertFile(JRubyAsciidoctor.java:400)
        at org.asciidoctor.jruby.internal.JRubyAsciidoctor.convertFile(JRubyAsciidoctor.java:419)
        at dev.snowdrop.AsciidoctorGenerator.main(AsciidoctorGenerator.java:25)
Caused by: org.jruby.exceptions.NoMethodError: (NoMethodError) asciidoctor: FAILED: /Users/dabou/Code/github/cmoulliard/playbook-doc/asciidoctor/all.adoc: Failed to load AsciiDoc document - undefined method `document' for #<Asciidoctor::PreprocessorReader:0x69d2e517>

public class AsciidoctorGenerator {

    public static void main(String[] args) {
        String adocFile = args[0];
        Asciidoctor asciidoctor = Asciidoctor.Factory.create();

        // Include the Table extension
        asciidoctor.javaExtensionRegistry()
                .preprocessor(FindRolesPreProcessor.class)
                .block(GenerateTableBlockProcessor.class);
        // Generate HTML
        asciidoctor.convertFile(
                new File(adocFile),
                OptionsBuilder.options()
                        .toFile(true)
                        .safe(SafeMode.UNSAFE));

Best

Charles
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard