-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't load reveal backend in ReactJS app #205
Comments
After spending 15 minutes researching this, I think I understand what's going on but I don't know how to fix it. I think our node package isn't webpack ready so you can't really Providing a gist of an example app that reproduce your problem and that we could try would be great because then I could try some things on my own to fix it. Right now, I know so little of Reactjs, webpack and Javascript that I'm completely lost on where to start.
Tagging @Mogztter to chime in as he is the most knowledgeable person I know on the Asciidoctor.js ecosystem. |
We encountered the same issue in the HTML5 semantic converter: jirutka/asciidoctor-html5s#2 In short, the Reveal.js converter should be lazily initialized otherwise the Asciidoctor context won't be available. You can take a look at what Jakub did: jirutka/asciidoctor-html5s@4702cb2 The warning about Please note that the warning message is not critical and Asciidoctor.js + Reveal.js converter should work fine. |
Thanks for the great pointers @Mogztter! @patoch, if you can provide a minimal broken example with as little code as possible, I will try to fix the problem with @Mogztter's guidance borrowing from the |
I can provide a minimal example using Babel: https://babeljs.io |
@obilodeau https://github.com/Mogztter/asciidoctor-reveal.js-integration-babel For reference the source code and the generated code: source.js import Asciidoctor from 'asciidoctor.js'
const asciidoctor = Asciidoctor()
import 'asciidoctor-reveal.js'
//require('asciidoctor-reveal.js')
const attributes = { revealjsdir: 'node_modules/reveal.js@' }
const options = {
safe: 'safe',
backend: 'revealjs',
attributes: attributes,
header_footer: true
}
console.log(asciidoctor.convert('Hello *Babel*', options)) generated.js 'use strict';
var _asciidoctor = require('asciidoctor.js');
var _asciidoctor2 = _interopRequireDefault(_asciidoctor);
require('asciidoctor-reveal.js');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var asciidoctor = (0, _asciidoctor2.default)();
// Babel will move the import statement at the top of the file.
// As a consequence, the reveal.js converter will be loaded before the initialization of Asciidoctor.js.
// If we replace the import statement by a require statement then it's working.
// Another way to fix this issue is to lazily load the reveal.js converter.
//require('asciidoctor-reveal.js')
var attributes = { revealjsdir: 'node_modules/reveal.js@' };
var options = {
safe: 'safe',
backend: 'revealjs',
attributes: attributes,
header_footer: true
};
console.log(asciidoctor.convert('Hello *Babel*', options)); @patoch Since you are already using import Asciidoctor from 'asciidoctor.js'
var asciidoctor = Asciidoctor()
require('asciidoctor-reveal.js')
var content = 'hello';
const attributes = { revealjsdir: 'node_modules/reveal.js@' }
const options = {
safe: 'safe',
backend: 'revealjs',
attributes: attributes,
header_footer: true
};
html = asciidoctor.convert(content, options) |
@obilodeau |
@Mogztter: should we fix the issue like in html5s or should we document the
require and proper initialization sequence?
I'm just so far off the use case I don't know which is better...
Le mar. 16 oct. 2018 3 h 47 p.m., Patrick Guillebert <
[email protected]> a écrit :
… @obilodeau <https://github.com/obilodeau>
Thank you for you response. I just tested and this works fine for me.
I would add this to the documentation, surely other people will be
interested to get this in the browser!
Thanks again !
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#205 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAhWFaN41FgveVMyKgTg2qS0bnf6770Hks5uljW1gaJpZM4XAtC1>
.
|
@obilodeau I believe it's a good practice to load a module "on demand". The import Asciidoctor from 'asciidoctor.js'
import AsciidoctorRevealjsConverter from 'asciidoctor-reveal.js'
const asciidoctor = Asciidoctor()
AsciidoctorRevealjsConverter.registrer() |
#219 is merged. Watch out when you will upgrade to our next release. |
Hi here,
I am trying to embed the reveal converter in a react web app and have the following :
Fails with :
Any clue how to get this run in the browser ?
Thank you
Patrick
The text was updated successfully, but these errors were encountered: