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

asciidoc-coalescer.rb ignores attributes in file #62

Closed tkfu closed 8 years ago

tkfu commented 8 years ago

This is a very minor issue, since it's got such an easy workaround, but I'm reporting it anyway.

If I have a doc with conditional formatting based on ifdef::[], the script ignores the attributes set in the file. They have to be passed via the command line. I would expect the following file to give me the english version when passed through the script, but it just gives me blank output. If I do ruby asciidoc-coalescer.rb -a en file.ad, however, I get the correct output.

:en:

ifdef::en[]
== My Document
English version

include::[some-file-en.ad]
endif::en[]

ifdef::pt[]
== Meu Documento
Versão em portugûes

include::[some-file-pt.ad]
endif::pt[]
mojavelinux commented 8 years ago

The behavior you are observing happens because the preprocessor reader only looks for preprocessor directives. It does not process attribute entries, or the document header.

I just submitted a fix in PR #63. With this change, the script now reads the document header to load all attribute entries defined there. It then passes all the attributes that are defined at the end of the header to the preprocessor reader. Let me know if that works for your use case.

I also documented what the script is doing better.