-
Notifications
You must be signed in to change notification settings - Fork 122
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
upgrade Asciidoctorj to 1.5.4.1 #258
Conversation
Tests are failing:
An error is thrown at this line: https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/converter/html5.rb#L300 slevel = (first_section = sections[0]).level
|
Strange. This is actually perfectly possible if multiple Asciidoctor instance come into play. If I fix this locally (by comparing the string representations of the symbols (Please don't beat me ;-) ) I stumble over the next problem:
Will investigate further. |
That's really weird because it means it gets past the following check:
However, if we look at the implementation of the
So the |
Is it possible that AsciidoctorJ is changing the symbol to a string? This would indicate that AsciidoctorJ is mutating the AST unexpectedly, which would indicate a bigger problem. Take a look at |
I think that’s a Bingo. We do not intentionally convert the context symbol to a String, but when iterating over the Blocks they are converted to the Java counterparts and replace the original Ruby objects. Now Asciidoctor Ruby calls getContext() on the Java Object, and that one returns a String and not a Symbol which would be useless in the Java API. But still not sure, where this comes from in 1.5.4.1 and why it doesn’t happen in 1.5.3.2.
|
Perhaps this is related somehow to asciidoctor/asciidoctorj#392 (adding an empty TreeProcessor in AsciidoctorJ 1.5.x kills the TOC). |
Completely strange. I just compared the changes in AsciidoctorJ between 1.5.3.2 and 1.5.4.1 and it's mostly build stuff, the addition of support for Tables in the AST and that's it besides additional tests :-( |
Did the version of JRuby change? |
It's nailed to 1.7.21 in the maven plugin Am Mittwoch, 10. August 2016 schrieb Dan Allen :
|
Another interesting observation: So it seems to be an unlucky combination of some changes in Asciidoctor and the fact that AsciidoctorJ mixes up the context symbols. |
Is it possibly related to asciidoctor/asciidoctor#1637 ? |
That definitely looks like the culprit. You could monkeypatch the |
I can't imagine that returning Symbols instead of Strings is possible. I already tried to fix it by comparing the context.to_s with "section" and it complained afterwards about getCaption() not implemented. :-) Monkey patching the original code seems awkward, but maybe the only possibility with 1.5.x. |
I totally agree. But that's not what I'm concerned about. What I'm hoping for is the internal state of the AST to remain unchanged. When Ruby executes |
I am not sure why the blocks are already replaced when iterating over them, but at latest when creating new sections in a processor it will be a pure Java object returning a String. Will try to monkey patch this on master. |
I'm okay with saying that creating new sections from a TreeProcessor in AsciidoctorJ 1.5.x while using the TOC is an unsupported scenario (instead, it requires AsciidoctorJ 1.6.x). I think the focus here is to get the TOC working when the TreeProcessor does not create new sections. |
Is Asciidoctorj 1.6.0 (final) coming out soon ?
|
No, there's still a lot of road in front of us. However, a beta could be on the horizon much sooner. I would encourage all early adopters to be using the beta of 1.6.0. Then we need to accelerate core. I've just been a bit overwhelmed at the moment to give that matter the attention it needs. |
Not converting the existing Ruby blocks is unfortunately also not an option. section.getBlocks() // would return a list of RubyObjectProxyHolders when using JavaEmbedUtils.rubyToJava()
.get(0) // Returns a RubyObject implementing AbstractBlock
.getBlocks() // Invokes the Ruby method Asciidoctor::AbstractBlock#blocks and returns an List of RubyObjects implementing nothing
.get(0) // ClassCastException: org.jruby.RubyObject cannot be cast to org.asciidoctor.ast.AbstractBlock I think patching the Symbol problem is the only option to go. |
I would say yes, but I think that the comparison to We might just have to say that you can't create Java-based TreeProcessor extensions with 1.5.x without side effects. |
I didn't find the time to completely dig through that. The thing I tried was replacing this: @blocks.select {|block| block.context == :section } with this: @block.select(|block| block.context.to_s == 'section' } I have unfortunately no clue about the performance impact this might have. I just wonder that we do not have a test case in AsciidoctorJ yet that reveals this problem, that should be the first task imo. |
The performance implication is extremely minor. That will certainly get the job done. |
Hi, this pull may already be closed, higher dependency versions are already in the master. |
You are right. Thanks for the heads up |
Resolves #257