asciidoctor / asciidoctor-extensions-lab

A lab for testing and demonstrating Asciidoctor extensions. Please do not use this code in production. If you want to use one of these extensions in your application, create a new project, import the code, and distribute it as a RubyGem. You can then request to make it a top-level project under the Asciidoctor organization.
Other
104 stars 101 forks source link

showcomments-preprocessor seems broken with latest asciidoctor #82

Closed maxandersen closed 6 years ago

maxandersen commented 6 years ago

Running:

asciidoctor -r ./lib/showcomments-preprocessor.rb lib/showcomments-preprocessor/sample.adoc

gives me:

/Users/max/code/asciidoctor-extensions-lab/lib/showcomments-preprocessor.rb:4:in `<top (required)>': uninitialized constant Extensions (NameError)
    from /Users/max/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/max/.rvm/rubies/ruby-2.3.3/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/max/.rvm/gems/ruby-2.3.3/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/options.rb:230:in `block in parse!'
    from /Users/max/.rvm/gems/ruby-2.3.3/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/options.rb:228:in `each'
    from /Users/max/.rvm/gems/ruby-2.3.3/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/options.rb:228:in `parse!'
    from /Users/max/.rvm/gems/ruby-2.3.3/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/options.rb:33:in `parse!'
    from /Users/max/.rvm/gems/ruby-2.3.3/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/invoker.rb:22:in `initialize'
    from /Users/max/.rvm/gems/ruby-2.3.3/gems/asciidoctor-1.5.6.1/bin/asciidoctor:12:in `new'
    from /Users/max/.rvm/gems/ruby-2.3.3/gems/asciidoctor-1.5.6.1/bin/asciidoctor:12:in `<top (required)>'
    from /Users/max/.rvm/gems/ruby-2.3.3/bin/asciidoctor:23:in `load'
    from /Users/max/.rvm/gems/ruby-2.3.3/bin/asciidoctor:23:in `<main>'
    from /Users/max/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `eval'
    from /Users/max/.rvm/gems/ruby-2.3.3/bin/ruby_executable_hooks:15:in `<main>'
maxandersen commented 6 years ago

fixed in #83; but had to use -a showcomments to get it work.

Just adding :showcomments: in sample.adoc was not enough. Is that expected ?

mojavelinux commented 6 years ago

Correct. That's because the preprocessor runs before a single line has been processed. So it doesn't see anything in the document. What you'd need to do is parse the document header in the preprocessor, then read any document attributes in the header. You can see this done in the tex-preprocessor.