anchor.diff:  
   === Using Asciidoctor and the native JavaScript environment from Ruby
   
  -First, we'll stuff some AsciiDoc data into a variable inside a Ruby script:
  +First, we'll stuff some AsciiDoc content into a variable inside a Ruby script:
   
   [source,ruby]
   ----
  -data = <<-EOS
  +content = <<-EOS
   = asciidoctor.js, AsciiDoc in JavaScript
   Doc Writer <docwriter@example.com>
   
  
positive.code: <script src="bower_components/asciidoctor.js/dist/asciidoctor-docbook.min.js"></script>
  ----
  
  All Opal-compiled classes are stored under the Opal namespace.
  Ruby variables and methods on a class or object get prefixed with `$`.
  Thus, where you would execute `Asciidoctor.convert` in Ruby, you execute `Opal.Asciidoctor.$convert` in JavaScript.
  
  [source,javascript]
  ----
  var html_doc =Opal.Asciidoctor.$convert(
      "http://asciidoctor.org[*Asciidoctor*] " +
      "running on http://opalrb.org[_Opal_] " +
      "brings AsciiDoc to the browser!")
  ----
  
  You would insert the rendered document into the page using the normal JavaScript DOM methods:
  
  [source,javascript]
  ----
  document.getElementById('content').innerHTML = Opal.Asciidoctor.$convert(
      "http://asciidoctor.org[*Asciidoctor*] " +
      "running on http://opalrb.org[_Opal_] " +
      "brings AsciiDoc to the browser!")
  ----
  
  Passing the options `Hash` to the `convert` method requires a little bit of Opal voodoo:
  
  [source,javascript]
  ----
  Opal.hash2(['attributes'], {'attributes': ['notitle!']})
  ----
  
  === Back-end development
  
  For back-end development, we use *npm*.
  
  Start by install *asciidoctor.js* module:
  
  [source, javascript]
  ----
  npm install asciidoctor.js --save
  ----
  
  You need to load file into your application.
  For instance, in a Javascript file, add these line:
  
  [source, javascript]
  ----
  var asciidoctorObject = require('asciidoctor.js')();
  
  // You can get Opal
  var opal = asciidoctorObject.Opal;
  
  // You can get Asciidoctor with Extensions ...
  var asciidoctorWithExtensions = asciidoctorObject.Asciidoctor(true);
  // ... or without extensions
  // var asciidoctorWithoutExtensions = asciidoctorObject.Asciidoctor();
  
  // Now you can use it
  var html = asciidoctorWithExtensions.$convert('== Test', opal.hash2(['attributes'], {'attributes': ['notitle!']}));
  
  // And for example log it
  console.log(html);
  
  /*
  // Should return
  <div class="sect1">
  <h2 id="_test">Test</h2>
  <div class="sectionbody">
  
  </div>
  </div>
  */
  ----
  
  
  == Changes to Asciidoctor (from upstream)
  
  Compiling Asciidoctor to JavaScript currently requires some changes in Asciidoctor.
  That's why the Asciidoctor source is linked into the project as a Git submodule.
  The goal is to eventually eliminate all of these differences so that Asciidoctor can be compiled to JavaScript as is.
  
  Here's a list of some of the changes that are currently needed:
  
  * Named posix groups in regular expressions are replaced with their ASCII equivalent
    - JavaScript doesn't support named posix groups, such as [x-]`[[:alpha:]]`)
  * A shim library is needed to implement missing classes in Opal, such as `Set`, `File` and `Dir`
  * All mutable String operations have been replaced with assignments
    - JavaScript doesn't support mutable strings
  * `$~[0]` used in place of `$&` and `$~[n]` in place of `$n` after running a regular expression (where n is 1, 2, 3...)
  * `Set` is missing difference and union operations
  * Opal doesn't recognize modifiers on a regular expression (e.g., multiline)
  * Optional, non-matching capture groups resolve to empty string in gsub block in Firefox (see http://www.bennadel.com/blog/1916-different-browsers-use-different-non-matching-captured-regex-pattern-values.htm)
  * Assignments without a matching value are set to empty string instead of nil (in the following example, `b` is set to empty string)
  
negative.code: image::https://travis-ci.org/asciidoctor/asciidoctor.js.svg?branch=master[Build Status, link=https://travis-ci.org/asciidoctor/asciidoctor.js]
  endif::[]
  
  This project uses {uri-opal}[Opal] to transcompile http://asciidoctor.org[Asciidoctor]—a modern implementation of AsciiDoc—from Ruby to JavaScript to produce [path]_asciidoctor.js_, bringing http://asciidoc.org[AsciiDoc] to the browser!
  
  == Introduction
  
  {sources}[Asciidoctor.js] is direct port of {uri-asciidoctor}[Asciidoctor] from Ruby to JavaScript using {uri-opal}[Opal], a Ruby-to-JavaScript transcompiler.
  It consists of a Rake build script that executes the Opal compiler on the Asciidoctor source code to produce the asciidoctor.js script.
  A Grunt build is used to assemble and prepare the distribution files, using the Rake build underneath.
  
  