-
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
By default the revealjsdir attribute, in a JavaScript and node environment, should be 'node_modules/reveal.js@' #191
Comments
I see your point. This will complicate doctests though but it's ok, they don't work yet. Oh and I'll fix them. Made some rough tests and something like this in slim seems to work: - if RUBY_ENGINE == 'opal'
- revealjsdir = (attr :revealjsdir, 'node_modules/reveal.js@')
- else
- revealjsdir = (attr :revealjsdir, 'reveal.js')
|
Opal only tells you that it's JavaScript, not necessarily that it's Node. But you can check for a Node environment either by the presence of this folder or Asciidoctor.js can tell you what environment it has loaded.
The @ allows the document to override the attribute. See https://asciidoctor.org/docs/user-manual/#altering-the-attribute-assignment-precedence |
But given current Javascript usage patterns, testing for Opal should suffice, no? I don't necessarily want to write a rather move involved test looking at the filesystem or trying to poke Asciidoctor.js's environment but having to add boilerplate code not to crash when called from Ruby.
Ah I forgot about that. But isn't the use of |
I think that would be closing doors on running the converter in the browser, as @Mogztter often points out.
Asciidoctor.js already does the hard work, so it's best to leverage the API it is providing. Specifically, you'd be looking at http://asciidoctor.github.io/asciidoctor.js/master/#asciidoctorgetruntime
No, that's just a shorthand for getting the attribute from the map.
Oops, my mistake. The @ doesn't apply in this context (and thus shouldn't be used). It's only used when invoking the converter (either via the API or the CLI). So ignore what I said before. |
Since we compile the slim templates to ruby then to javascript with Opal and releasing the result as an npm package, anything consuming that package would have the How is that javascript going to be distributed to the browser otherwise? |
I looked at the API and I don't see how we will be able to call it from the slim templates... Googling for "Opal inline javascript" didn't give what I expected. Guidance required. |
Using browserify / webpack (and then probably bundled with a program, such as with AsciidocFX). But then it would be incorrect to look in node_modules to find reveal.js. Of course, that doesn't rule out that integration simply overridding the value. Still, we shouldn't assume anywhere that RUBY_ENGINE == 'opal' is Node as a general practice. |
Inside the
keep in mind this constant will not be defined in Ruby, so it has to be inside the Here's where all this gets defined: https://github.com/asciidoctor/asciidoctor.js/blob/master/lib/asciidoctor/js/opal_ext/node.rb |
I defer to @Mogztter to confirm. |
Discussed with @Mogztter last week on twitter. PR is coming. |
PR is #228 |
Added a different default value for revealjsdir under node (fixes #191)
It will make the installation/configuration easier.
The text was updated successfully, but these errors were encountered: