Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #497. Patch Asciidoctor::AbstractBlock#section? in abstract_blo… #498

Merged
merged 1 commit into from
Aug 13, 2016

Conversation

robertpanzer
Copy link
Member

…ck.rb to return context by string instead of Symbol because Java blocks always return strings.

There's a problem currently in the way AsciidoctorJ 1.5.x sits on top of Asciidoctor:
It replaces all blocks in the AST once touched by a processor by their Java counterparts, which is necessary.
This makes it impossible for public methods exposed via the Java API to return Ruby specifics like for example Ruby Symbols.

There's a recent change in Asciidoctor 1.5.4 that uses the result of Asciidoctor::AbstractBlock#context and compares it to :section.
As the Java object returns a String instead of a Symbol this test always fails and therefore the error described in asciidoctor/asciidoctor-maven-plugin#258 and filed in #497 occurs.

This PR fixes this by

  1. patching abstract_block.rb to compare the String representation of the symbol instead of the symbol
  2. Implementing the methods in SectionImpl and AbstractBlockImpl necessary to build a table of contents.

Also tested locally building the asciidoctor-maven-plugin.

// convince Asciidoctor PDF to use the thread_safe 0.3.4 provided by AsciidoctorJ
if (it.path == 'gems/asciidoctor-1.5.4/lib/asciidoctor/abstract_block.rb') {
it.filter { line ->
line.replaceAll(/block.context == :section/, 'block.context.to_s == \'section\'')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you could almost eliminate any overhead by writing it as:

block.context.to_sym == :section

@mojavelinux
Copy link
Member

Very nice explanation! And thanks for making this fix.

…bstract_block.rb to return context by string instead of Symbol because Java blocks always return strings.
@abelsromero
Copy link
Member

Since this has been merged and tested with the maven plugin, do you think it makes sense to do a 1.5.4.2 release?
With that we can do a 1.5.4 release of the maven-plugin that passes all tests.

@robertpanzer
Copy link
Member Author

Sounds like a good idea.
I wanted to get asciidoctorj-pdf finished before though.

If we think this is more urgent though, I can also do a release with the old asciidoctorj-pdf.

@abelsromero
Copy link
Member

Not urgent, more like something that I should have done before. But still, we can take some time to polish the asciidoctorj-pdf project first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants