Upgrading Asciidoctor.js to the latest version of Asciidoctor

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Upgrading Asciidoctor.js to the latest version of Asciidoctor

ggrossetie
Ok, I will ask Adam.

Good news I can now render document with Asciidoctor master !!! Ahhhhhhh ! :D



Sure there is still some work to do but it make me happy to finally see something other than Javascript errors :)


Cheers,
Guillaume.
Reply | Threaded
Open this post in threaded view
|

Re: Upgrading Asciidoctor.js to the latest version of Asciidoctor

mojavelinux
Administrator
Great work Guillaume! I can render a document now too. It's pretty exciting when you see it the first time, isn't it? We're getting close! Exciting!!

I've got some feedback from my hacking last night that should move us forward on a couple things. I'll cover them in a follow-up post.

-Dan


On Sat, Oct 19, 2013 at 5:38 PM, ggrossetie [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Ok, I will ask Adam.

Good news I can now render document with Asciidoctor master !!! Ahhhhhhh ! :D



Sure there is still some work to do but it make me happy to finally see something other than Javascript errors :)


Cheers,
Guillaume.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Upgrading-Asciidoctor-js-to-the-latest-version-of-Asciidoctor-tp636p829.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Upgrading Asciidoctor.js to the latest version of Asciidoctor

mojavelinux
Administrator
In reply to this post by ggrossetie
On Sat, Oct 19, 2013 at 4:15 PM, ggrossetie [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi, I'm stuck with an error and I don't know how to handle this case. The warn method from the Kernel module is not found by Opal:
Uncaught NoMethodError: undefined method `warn' for Asciidoctor::Lexer
This is just another missing method in Opal. We need to file and issue to get it resolved upstream. Until then, we can add an opal_ext file:

[source,ruby]
.asciidoctor/opal_ext/kernel.rb
--
class Kernel
  def warn(*strs)
    $stderr.puts(*strs)
  end
end

def $stderr.puts(*strs)
  %x{
    for (var i = 0; i < strs.length; i++) {
      if(strs[i] instanceof Array) {
        #{ puts(*`strs[i]`) }
      } else {
        console.warn(#{`strs[i]`.to_s});
      }
    }
  }
  nil
end
--

 
I tried to add "require 'kernel'" to solve this issue and it nearly worked... but then Opal mixed up definition of methods. For example the =~ method now use the implementation of the Kernel module (opal/corelib/kernel.rb) instead of the implementation of the String class or Regexp class :
module Kernel
# ...
  def =~(obj)
    false
  end
end
# ...
Any idea ? Maybe it's some kind of "bug" or limitation in Opal ?

I'm seeing the same problem, but not just when I add the warn method implementation. There appears to be a regression in Opal. It's now adding the definition of Kernel in asciidoctor.js, which clobbers the method overrides in all sub-types. If I remove the duplicate Kernel definition in asciidoctor.js, then everything works.

Look for the following block to remove:

[source,javascript]
--
(function($opal) {
  var self = $opal.top, $scope = $opal, nil = $opal.nil, $breaker = $opal.breaker, $slice = $opal.slice, $module = $opal.module, $gvars = $opal.gvars;
  return (function($base){
    var self = $module($base, "Kernel");
    var def = self._proto, $scope = self._scope, TMP_1, TMP_2, TMP_3, TMP_4, TMP_5, TMP_6, TMP_8;

    def.$method_missing = TMP_1 = function(symbol, args) {
      var self = this, $iter = TMP_1._p, block = $iter || nil;TMP_1._p = null;args = $slice.call(arguments, 1);
      return self.$raise($scope.NoMethodError, "undefined method `" + (symbol) + "' for " + (self.$inspect()));
    };

...snip...

  })(self)
})(Opal);
--

I need to figure out why we are getting this duplicate so I can explain it in an issue.

-Dan

--
Reply | Threaded
Open this post in threaded view
|

Re: Upgrading Asciidoctor.js to the latest version of Asciidoctor

mojavelinux
Administrator
In reply to this post by ggrossetie
On Sun, Oct 20, 2013 at 12:59 PM, Dan Allen <[hidden email]> wrote:
On Sat, Oct 19, 2013 at 4:15 PM, ggrossetie [via Asciidoctor :: Discussion] <[hidden email]> wrote:
 
I tried to add "require 'kernel'" to solve this issue and it nearly worked... but then Opal mixed up definition of methods. For example the =~ method now use the implementation of the Kernel module (opal/corelib/kernel.rb) instead of the implementation of the String class or Regexp class :
module Kernel
# ...
  def =~(obj)
    false
  end
end
# ...
Any idea ? Maybe it's some kind of "bug" or limitation in Opal ?

I'm seeing the same problem, but not just when I add the warn method implementation. There appears to be a regression in Opal. It's now adding the definition of Kernel in asciidoctor.js, which clobbers the method overrides in all sub-types. If I remove the duplicate Kernel definition in asciidoctor.js, then everything works.

Oh, I see what the problem is. The require 'kernel' line you add in lexer.rb was still there. You should never need to require the kernel, so I removed it and it all works again.

No regression in Opal :)

-Dan

--
12