Nashorn/Asciidoctor.js and InputOutput files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Nashorn/Asciidoctor.js and InputOutput files

asotobu
Hello,

currently I am developing the integration between asciidocotr.js with Nashorn. In this integration I have found two barriers, the first one is a bug on Nashorn, so in this case we cannot do anything rather than wait until a new update of JDK8 is released with the bug fixed by Nashorn team. The other barrier is the IO.

By default Nashorn does not provide an IO management, so we need a way to modify the javascript generated by Opal to allow us add some Java code for reading and writing files.

I think we must do something similar as it has been done for Node.js, first of all detect if we are running within Nashorn and if it is the case do the file management.

To detect if we code is being run inside Nashorn is as easy as:

try {
  Java.type('java.lang.String');
} catch(err) {
  return false;
}

So the question is if it is identified all the places where asciidoctor.js needs to access the filesystem and what is the experience when it was done for Node.js.
Reply | Threaded
Open this post in threaded view
|

Re: Nashorn/Asciidoctor.js and InputOutput files

ggrossetie
Hi Alex,

I think you will cover most of the cases if you add your code here : https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/opal_ext/file.rb#L98
That was we have done for Node.js and includes are working fine :)

Guillaume.


Reply | Threaded
Open this post in threaded view
|

Re: Nashorn/Asciidoctor.js and InputOutput files

asotobu
Do you think it may work in case I set to_file attribute as well or it is only used in include macro

El dilluns, 29 setembre de 2014, ggrossetie [via Asciidoctor :: Discussion] <[hidden email]> va escriure:
Hi Alex,

I think you will cover most of the cases if you add your code here : https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/opal_ext/file.rb#L98
That was we have done for Node.js and includes are working fine :)

Guillaume.





If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Nashorn-Asciidoctor-js-and-InputOutput-files-tp2299p2302.html
To unsubscribe from Nashorn/Asciidoctor.js and InputOutput files, click here.
NAML


--
Enviat amb Gmail Mobile
Reply | Threaded
Open this post in threaded view
|

Re: Nashorn/Asciidoctor.js and InputOutput files

ggrossetie
I'm not sure but with a quick look on the convert method https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor.rb#L1387 I think this will not be enough.
Could you make a test and let's see what happens ?
Reply | Threaded
Open this post in threaded view
|

Re: Nashorn/Asciidoctor.js and InputOutput files

mojavelinux
Administrator
In reply to this post by asotobu

On Mon, Sep 29, 2014 at 11:32 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Do you think it may work in case I set to_file attribute as well or it is only used in include macro

I'm pretty sure that if you implement the static read method in the file class (https://github.com/asciidoctor/asciidoctor/blob/master/lib/asciidoctor/opal_ext/file.rb) that should cover all cases as it has proven to be true in the browser extensions. If corner cases come up, we can address them when they do.