From b8962c308aa15188fa5a8b3bcb81f0cf5e8326e3 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Mon, 1 Apr 2019 09:02:10 +0200 Subject: [PATCH 1/5] Upgrade to Asciidoctor.js 2.0.0 --- README.adoc | 34 +++++++++++++++++--- npm/examples.js | 2 +- package-lock.json | 79 ++++++++++++++++++++++++++++++----------------- package.json | 16 +++++----- test/smoke.js | 4 +-- 5 files changed, 89 insertions(+), 46 deletions(-) diff --git a/README.adoc b/README.adoc index fdb8fa77..4819417c 100644 --- a/README.adoc +++ b/README.adoc @@ -136,10 +136,9 @@ First you must install and configure {uri-nodejs-download}[Node.js] on your mach Using npm: -Create a directory to place slides. Initialize the directory to store npm packages within that directory. +Create a directory to place slides. Initialize the directory to store npm packages within that directory. - $ echo {} > package.json # eliminates warnings, use `npm init` if you prefer - $ npm i --save asciidoctor-reveal.js + $ npm i --save asciidoctor asciidoctor-reveal.js === Rendering the AsciiDoc into slides @@ -173,9 +172,34 @@ asciidoctor.convertFile('presentation.adoc', options); // <1> ---- -To render the slides, run: +To convert the sample presentation into slides, open a terminal and type: - node asciidoctor-revealjs.js + $ $(npm bin)/asciidoctor -r asciidoctor-reveal.js -b revealjs presentation.adoc + +The above command will generate a file named [.path]_presentation.html_. +You can open this file in a browser. + +==== Using the JavaScript API + +Alternatively, you can use the JavaScript API to register the converter and convert a document: + +.convert-slides.js +[source,javascript] +---- +// Load Asciidoctor.js and the reveal.js converter +var asciidoctor = require('@asciidoctor/core')() +var asciidoctorRevealjs = require('asciidoctor-reveal.js') +asciidoctorRevealjs.register() + +// Convert the document 'presentation.adoc' using the reveal.js converter +var options = { safe: 'safe', backend: 'revealjs' } +asciidoctor.convertFile('presentation.adoc', options) // <1> +---- +<1> Creates a file named `presentation.html` (in the directory where command is run) + +To execute the script, open a terminal and type: + + $ node convert-slides.js You can open the `presentation.html` file in your browser and enjoy! diff --git a/npm/examples.js b/npm/examples.js index 49543d25..647fb69e 100644 --- a/npm/examples.js +++ b/npm/examples.js @@ -7,7 +7,7 @@ const examplesDir = 'examples'; log.task('examples'); // Load asciidoctor.js and local asciidoctor-reveal.js -const asciidoctor = require('asciidoctor.js')(); +const asciidoctor = require('@asciidoctor/core')(); const asciidoctorRevealjs = require('../build/asciidoctor-reveal.js'); // Register the reveal.js converter diff --git a/package-lock.json b/package-lock.json index 353ba8ca..e07bfc73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,34 @@ { "name": "asciidoctor-reveal.js", - "version": "2.0.0", + "version": "2.0.2-dev", "lockfileVersion": 1, "requires": true, "dependencies": { - "asciidoctor.js": { - "version": "1.5.9", - "resolved": "https://registry.npmjs.org/asciidoctor.js/-/asciidoctor.js-1.5.9.tgz", - "integrity": "sha512-k5JgwyV82TsiCpnYbDPReuHhzf/vRUt6NaZ+OGywkDDGeGG/CPfvN2Gd1MJ0iIZKDyuk4iJHOdY/2x1KBrWMzA==", + "@asciidoctor/core": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@asciidoctor/core/-/core-2.0.0.tgz", + "integrity": "sha512-Vd3L9oAy4wxk/f4UHd/tyABqDwUOHarYKfvNSV5GtqJ8S1QvF2hOa5bl3f8/g9sOSbf3HUm7oXqGY33mxTd1tw==", + "dev": true, "requires": { - "opal-runtime": "1.0.11" + "asciidoctor-opal-runtime": "0.3.0", + "unxhr": "1.0.1" + } + }, + "asciidoctor-opal-runtime": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/asciidoctor-opal-runtime/-/asciidoctor-opal-runtime-0.3.0.tgz", + "integrity": "sha512-YapVwl2qbbs6sIe1dvAlMpBzQksFVTSa2HOduOKFNhZlE9bNmn+moDgGVvjWPbzMPo/g8gItyTHfWB2u7bQxag==", + "dev": true, + "requires": { + "glob": "7.1.3", + "unxhr": "1.0.1" } }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true }, "bestikk-log": { "version": "0.1.0", @@ -30,6 +43,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -44,7 +58,8 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "expect.js": { "version": "0.3.1", @@ -52,14 +67,22 @@ "integrity": "sha1-sKWaDS7/VDdUTr8M6qYBWEHQm1s=", "dev": true }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, "glob": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", - "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, "requires": { + "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "2 || 3", + "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } @@ -68,6 +91,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -76,12 +100,14 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -90,38 +116,33 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } }, - "opal-runtime": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/opal-runtime/-/opal-runtime-1.0.11.tgz", - "integrity": "sha512-L+6pnRvXPlDtbamBRnJAnB9mEMXmsIQ/b+0r/2xJ5/n/nxheEkLo+Pm5QNQ08LEbEN9TI6/kedhIspqRRu6tXA==", - "requires": { - "glob": "6.0.4", - "xmlhttprequest": "1.8.0" - } - }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true }, "reveal.js": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/reveal.js/-/reveal.js-3.7.0.tgz", "integrity": "sha512-HTOTNhF5mQAw6fcsptk4oql/DEEUwTG0YHk/LzTNNx0/3IgvOQZqKzvlK/zNpqqKMLlhn1gH9Nvp+FFoc/e5/w==" }, + "unxhr": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unxhr/-/unxhr-1.0.1.tgz", + "integrity": "sha512-MAhukhVHyaLGDjyDYhy8gVjWJyhTECCdNsLwlMoGFoNJ3o79fpQhtQuzmAE4IxCMDwraF4cW8ZjpAV0m9CRQbg==", + "dev": true + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "xmlhttprequest": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", - "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true } } } diff --git a/package.json b/package.json index e591fa3c..c8404a3f 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,11 @@ "description": "A reveal.js converter for Asciidoctor.js. Write your slides in AsciiDoc!", "main": "dist/main.js", "engines": { - "node": ">=4", - "npm": ">=3.0.0" + "node": ">=8.11", + "npm": ">=5.0.0" }, - "files": [ - "dist", - "LICENSE.adoc", - "README.adoc" - ], + "files": [], "scripts": { - "build": "node npm/build.js", "test": "node test/smoke.js", "examples": "node npm/examples.js" }, @@ -21,6 +16,9 @@ "type": "git", "url": "https://github.com/asciidoctor/asciidoctor-reveal.js.git" }, + "publishConfig": { + "access": "public" + }, "keywords": [ "asciidoc", "asciidoctor", @@ -41,10 +39,10 @@ }, "homepage": "https://github.com/asciidoctor/asciidoctor-reveal.js", "dependencies": { - "asciidoctor.js": "1.5.9", "reveal.js": "3.7.0" }, "devDependencies": { + "@asciidoctor/core": "^2.0.0", "bestikk-log": "0.1.0", "expect.js": "0.3.1" } diff --git a/test/smoke.js b/test/smoke.js index a73a31a1..9c37c407 100644 --- a/test/smoke.js +++ b/test/smoke.js @@ -1,4 +1,4 @@ -const asciidoctor = require('asciidoctor.js')() +const asciidoctor = require('@asciidoctor/core')() const asciidoctorRevealjs = require('../dist/main.js') //require('../dist/main.js') @@ -7,7 +7,7 @@ const expect = require('expect.js') // Register the reveal.js converter asciidoctorRevealjs.register() -const options = {safe: 'safe', backend: 'revealjs', 'header_footer': true} +const options = {safe: 'safe', backend: 'revealjs', standalone: true} const content = `= Title Slide == Slide One From 75cf2f04e7af00fe0ef784ea4b6831b0a67219f6 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Thu, 28 Nov 2019 10:41:13 +0100 Subject: [PATCH 2/5] Remove jade keyword (as we are now using Slim templates transpiled to JS) --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index c8404a3f..0cadab07 100644 --- a/package.json +++ b/package.json @@ -27,8 +27,7 @@ "library", "backend", "template", - "reveal.js", - "jade" + "reveal.js" ], "authors": [ "Guillaume Grossetie (https://github.com/mogztter)" From 8779751d6e9d0d6f878ab4795a442aa1259d1786 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Thu, 28 Nov 2019 10:41:38 +0100 Subject: [PATCH 3/5] Add Olivier as a contributor --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 0cadab07..009727d0 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "reveal.js" ], "authors": [ + "Olivier Bilodeau (https://github.com/obilodeau)", "Guillaume Grossetie (https://github.com/mogztter)" ], "license": "MIT", From cdd1cea27ba6896120f68f27d0b4abd048f72092 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Thu, 28 Nov 2019 11:40:41 +0100 Subject: [PATCH 4/5] Explain how to use the Asciidoctor CLI to convert an AsciiDoc file into slides --- README.adoc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/README.adoc b/README.adoc index 4819417c..bc3ec516 100644 --- a/README.adoc +++ b/README.adoc @@ -130,37 +130,38 @@ TIP: If you are using https://pages.github.com/[GitHub Pages], plan ahead by kee === Prerequisites -First you must install and configure {uri-nodejs-download}[Node.js] on your machine. +First you must install and configure {uri-nodejs-download}[Node] on your machine. === Install -Using npm: +We recommend to install the dependencies in a project directory, such as the directory where your AsciiDoc presentations are stored. +If you don't have a `package.json` file in your project directory, you can create one to eliminate warnings during the installation using: -Create a directory to place slides. Initialize the directory to store npm packages within that directory. + $ echo {} > package.json # or `npm init` if you prefer + +You can now install the dependencies: $ npm i --save asciidoctor asciidoctor-reveal.js -=== Rendering the AsciiDoc into slides +=== Convert AsciiDoc into slides -Once the package is installed, you can convert AsciiDoc files using reveal.js converter. -Here we are converting a file named `presentation.adoc` into a reveal.js presentation using Node.js: +Once the dependencies are installed, verify that the `asciidoctor` command is available by running: -.asciidoctor-revealjs.js -[source, javascript] ----- -// Load asciidoctor.js and asciidoctor-reveal.js -var asciidoctor = require('asciidoctor.js')(); -var asciidoctorRevealjs = require('asciidoctor-reveal.js'); -asciidoctorRevealjs.register() + $ $(npm bin)/asciidoctor --version -// Convert the document 'presentation.adoc' using the reveal.js converter -var options = {safe: 'safe', backend: 'revealjs'}; -asciidoctor.convertFile('presentation.adoc', options); // <1> +The command should report the Asciidoctor CLI version in the terminal: + +[source,console] ---- -<1> Creates a file named `presentation.html` (in the directory where command is run) +Asciidoctor.js 2.0.3 (Asciidoctor 2.0.9) [https://asciidoctor.org] +Runtime Environment (node v10.15.1 on linux) +CLI version 2.0.1 +---- + +If you don't have an existing presentation, you can create a sample presentation named [.path]_presentation.adoc_: .presentation.adoc -[source, asciidoc] +[source,asciidoc] ---- = Title Slide @@ -203,7 +204,6 @@ To execute the script, open a terminal and type: You can open the `presentation.html` file in your browser and enjoy! - == Syntax Examples Let's see some examples of `revealjs` backend features. From 9293b8d73ddce493c4fe8d36728f2aa8c3c639a4 Mon Sep 17 00:00:00 2001 From: Guillaume Grossetie Date: Mon, 9 Dec 2019 16:28:19 +0100 Subject: [PATCH 5/5] Make the documentation Windows friendly --- README.adoc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.adoc b/README.adoc index bc3ec516..d2cf2bb8 100644 --- a/README.adoc +++ b/README.adoc @@ -137,7 +137,7 @@ First you must install and configure {uri-nodejs-download}[Node] on your machine We recommend to install the dependencies in a project directory, such as the directory where your AsciiDoc presentations are stored. If you don't have a `package.json` file in your project directory, you can create one to eliminate warnings during the installation using: - $ echo {} > package.json # or `npm init` if you prefer + $ npm init -y You can now install the dependencies: @@ -145,10 +145,15 @@ You can now install the dependencies: === Convert AsciiDoc into slides -Once the dependencies are installed, verify that the `asciidoctor` command is available by running: +Once the dependencies are installed, verify that the `asciidoctor` command is available. +On Linux and macOS, open a terminal and type: $ $(npm bin)/asciidoctor --version +On Windows, open PowerShell and type: + + $ .\node_modules\.bin\asciidoctor.cmd --version + The command should report the Asciidoctor CLI version in the terminal: [source,console] @@ -177,6 +182,10 @@ To convert the sample presentation into slides, open a terminal and type: $ $(npm bin)/asciidoctor -r asciidoctor-reveal.js -b revealjs presentation.adoc +On windows, open PowerShell and type: + + $ .\node_modules\.bin\asciidoctor.cmd -r asciidoctor-reveal.js -b revealjs presentation.adoc + The above command will generate a file named [.path]_presentation.html_. You can open this file in a browser.