Login  Register

Re: copycss attribute causes exception in asciidoctor-java-integration

Posted by mojavelinux on May 15, 2013; 8:54pm
URL: https://discuss.asciidoctor.org/copycss-attribute-causes-exception-in-asciidoctor-java-integration-tp179p203.html

Alex et al,

I've done some thinking about this and I absolutely like the idea of being able to have Asciidoctor pass information about the file it wants to read to the integration layer and allow the integration layer to read it.

For the default stylesheet however, since it's a very special case...at least for now, I'm going to store the content in a string so that there is no need to locate a file to read the content. There are a few reasons for doing it this way...but most importantly it keeps things self contained for handling such a core use case.

Here's the pull request for that change. This will solve the immediate copycss problem in the integration layer...because now we are not reading a file:


When we get into bundles themes and perhaps backends, then we will need to use the integration that Alex is proposing. It's still critical.

-Dan


On Sun, May 5, 2013 at 12:34 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Dan suggested in the issue:

After giving it some more thought, I realized there is a third solution. I can put the default CSS into a constant in a Ruby file, then load that Ruby file using require when it is needed and read the value off the constant.

...which brings up another data point when looking into this issue. Somewhere in JRuby (I think in JRubyKernel.java), JRuby is able to read files out of the classpath for the require statement. Thus, there must be some way in Ruby to read the file contents from a file on the LOAD_PATH without evaluating it. Maybe Kernel#open?


and I have replied there and now I write here too:

Ok, then one idea that I was discarding at first (implementing copycss feature inside java). it seems that would be the best one. I agree that the best way would be trying to read the file from the gem with a method (Kernel#open) could be an option if works. But it comes to my mind one thing:

If we add a specific behaviour in one attribute, maybe in future we will add another one, and another one, ... and we can finish by having some logic duplicated in Java and Ruby part. I think this would not be the case, but opens the door to do it again.

Of course I think third option could be the best one, but I don't like this duplication.




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/copycss-attribute-causes-exception-in-asciidoctor-java-integration-tp179p182.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | http://google.com/profiles/dan.j.allen