<commit_before>= Contributing Code
// settings:
:experimental:
:idprefix:
:idseparator: -
:toc: preamble
// URIs:
:uri-nodejs: http://nodejs.org
:uri-opal: http://opalrb.org
:uri-nvm: https://github.com/creationix/nvm
:uri-asciidoctor: http://asciidoctor.org
:uri-repo: https://github.com/asciidoctor/asciidoctor.js

This guide will give you all the necessary information you need to become a successful Asciidoctor.js developer and code contributor!

== Introduction

{uri-repo}[Asciidoctor.js] is direct port of {uri-asciidoctor}[Asciidoctor] from Ruby to JavaScript using {uri-opal}[Opal], a Ruby-to-JavaScript transpiler.
The project includes a npm build script that executes the Opal compiler on the Asciidoctor source code to produce the Asciidoctor.js scripts.

Opal parses the Ruby code and any required libraries, then rewrites the code into JavaScript under the Opal namespace.
The resulting JavaScript can be executed within any JavaScript runtime environment (such as a browser).

To interact with the generated code, you either invoke the JavaScript APIs directly, or you can invoke native JavaScript objects from within the Ruby code prior to compilation.

== Setup

To build Asciidoctor.js, you'll need some tools:

* {uri-nodejs}[Node.js] >= 8 and npm (we recommend {uri-nvm}[nvm] to manage multiple active Node.js versions)

Start by cloning the source from GitHub:

 $ git clone https://github.com/asciidoctor/asciidoctor.js.git

Next, switch to the _asciidoctor.js_ directory and run npm's `install` command:

 $ cd asciidoctor.js
   npm install

You're now ready to build Asciidoctor.js.

TIP: Opal.js, the Ruby runtime in JavaScript is available in `node_modules/opal-runtime/src/opal.js`

== Building

This section describes how to build Asciidoctor.js from source, execute the tests and try out the examples.

=== Building Asciidoctor.js

To build Asciidoctor.js, simply run the npm `build` script from the root of the project:

 $ npm run build

NOTE: The build task will make some minor code changes on Asciidoctor Ruby code.
As you may know String are immutable in JavaScript, so we need to replace `gsub!` and `sub!` methods.
These changes are made at build time to keep the Ruby code as fast as possible.

This command produces a file named `asciidoctor.js` in the [path]_build_ directory.
This file contains everything you need to use Asciidoctor in a JavaScript environment.

You'll see this script in action when you run the examples, described next.

=== Building and running the examples<commit_msg>✏️ Fix typos in code contribution document (#613)<commit_after>= Contributing Code
// settings:
:experimental:
:idprefix:
:idseparator: -
:toc: preamble
// URIs:
:uri-nodejs: http://nodejs.org
:uri-opal: http://opalrb.org
:uri-nvm: https://github.com/creationix/nvm
:uri-asciidoctor: http://asciidoctor.org
:uri-repo: https://github.com/asciidoctor/asciidoctor.js
:uri-mdn-string: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type

This guide will give you all the necessary information you need to become a successful Asciidoctor.js developer and code contributor!

== Introduction

{uri-repo}[Asciidoctor.js] is a direct port of {uri-asciidoctor}[Asciidoctor] from Ruby to JavaScript using {uri-opal}[Opal], a Ruby-to-JavaScript transpiler.
The project includes a npm build script that executes the Opal compiler on the Asciidoctor source code to produce the Asciidoctor.js scripts.

Opal parses the Ruby code and any required libraries, then rewrites the code into JavaScript under the Opal namespace.
The resulting JavaScript can be executed within any JavaScript runtime environment (such as a browser).

To interact with the generated code, you either invoke the JavaScript APIs directly, or you can invoke native JavaScript objects from within the Ruby code prior to compilation.

== Setup

To build Asciidoctor.js, you'll need some tools:

* {uri-nodejs}[Node.js] >= 8 and npm (we recommend {uri-nvm}[nvm] to manage multiple active Node.js versions)

Start by cloning the source from GitHub:

 $ git clone https://github.com/asciidoctor/asciidoctor.js.git

Next, switch to the _asciidoctor.js_ directory and run npm's `install` command:

 $ cd asciidoctor.js
   npm install

You're now ready to build Asciidoctor.js.

TIP: Opal.js, the Ruby runtime in JavaScript is available in `node_modules/opal-runtime/src/opal.js`

== Building

This section describes how to build Asciidoctor.js from source, execute the tests and try out the examples.

=== Building Asciidoctor.js

To build Asciidoctor.js, simply run the npm `build` script from the root of the project:

 $ npm run build

NOTE: The build task will make some minor code changes on Asciidoctor Ruby code.
As you may know, {uri-mdn-string}[strings are immutable] in JavaScript, so we need to replace the `gsub!` and `sub!` methods.
These changes are made at build time to keep the Ruby code as fast as possible.

This command produces a file named `asciidoctor.js` in the [path]_build_ directory.
This file contains everything you need to use Asciidoctor in a JavaScript environment.

You'll see this script in action when you run the examples, described next.

=== Building and running the examples
{'fraction_non_alphanumeric': 0.07652573177731012, 'fraction_numerical': 0.0009565716472163765, 'mean_word_length': 4.670281995661605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5286883', 'n_tokens_mistral': 1533, 'n_tokens_neox': 1478, 'n_words': 672}