Login  Register

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

Posted by mojavelinux on Sep 24, 2013; 7:55am
URL: https://discuss.asciidoctor.org/Upgrading-Asciidoctor-js-to-the-latest-version-of-Asciidoctor-tp636p643.html

Great work Guillaume! You got past the hardest part of any project, which is making the compiler happy :)

It looks like some regressions have snuck into Opal since the last time I compiled asciidoctor.js. Asciidoctor gives Opal a thorough workout, so chances are you've found a real regression. I encourage you to open an issue with Opal and give fixing it a go. The Opal guys (Adam and Elia) are really cool and welcoming. The test suite in Opal is just like a normal Ruby unit test suite, so it's really easy to get running.

I have good news for you as well!!! I just finished updating all the html5 erb templates for Asciidoctor 0.1.4!

You can find the templates in the https://github.com/asciidoctor/asciidoctor-backends/tree/master/erb/html5 repository. These are drop-in replacements for the opalerb files in Asciidoctor.js. Just change the file extension from .html.erb to .opalerb and copy them to lib/backends/html5.

Of course, the templates depend on the 0.1.4 core, so they'll only be useful once you get that part upgraded. Since the changes from 0.1.2 to 0.1.4 are rather significant, I think it's best to look at the diff applied to asciidoctor in asciidoctor.js, understand what needed to be changed, and reapply those changes. That will also help you become familiar with what we need to change upstream to eliminate (or reduce) the number of differences needed.

The changes basically boil down to:

* OPAL constant <= this we can apply upstream for 1.5.0
* addition of a compat library to close gaps in Opal <= this we can apply upstream for 1.5.0
* load libraries explicitly (since everything is statically compiled)
* string modifications must be changed to assignments (cannot use chop! for instance)
* differences in regex character classes <= these we can apply upstream for 1.5.0
* load and use opalerb templates instead of built-in templates
* cannot use Struct (need to use concrete class) <= this we can apply upstream for 1.5.0
* destruct assignments weren't working last I checked in Opal
* regexps don't match endline at end of line, so need to add endlines only during output (this is a significant change, though I'd like to make it in 1.5.0 if possible)

A good first step is to complete this list of incompatibilities so that we have a good understanding of what we are changing. You can keep track of them in the README. Once you that picture in focus, applying the rules goes very quickly...and you can convert just about any Ruby code :)

If you have any questions, please don't hesitate to ask. I'll definitely pitch in to help out whenever I can.

-Dan

--
Dan Allen | http://google.com/profiles/dan.j.allen