Comments (6)
That sounds like a great idea!
On Thu, May 9, 2013 at 4:20 AM, Alex Soto [email protected] wrote:
the Asciidoctor Java integration could preload specified libraries when it
boots JRuby, removing the possibility of any problems or warnings.Related with Issue rmannibucau/JeBlog#1
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/32
.
Jason Porter
http://en.gravatar.com/lightguardjp
from asciidoctorj.
Yes I think so, another thing to research, briefly with @ajuckel we will have OSGI integration (Which maybe also fixes the problem with AS 7). Also I am working with copycss problem, and then it will be the time for preloading libraries. Of course if you have any idea feel free to write it here.
from asciidoctorj.
I think that preloading libraries should work perhaps like the ruby cli. If you run ruby -h
, you'll see:
-rlibrary require the library before executing your script
This option can be passed multiple times. Therefore, it's reasonable for the Asciidoctor Factory method (or something similar) accept an array of library names to load. For now, we can assume these libraries are available on the Ruby LOAD_PATH and thus a simple string name will do.
We could do some smart preloading:
- if the
source-highlighter
option is set tocoderay
, we could automatically add 'coderay' to the preload list - If the
eruby
option is set toerubis
, we could automatically adderubis
to the preload list - If the
template_dir
option is specified, we could automatically addtilt
to the preload list (and maybe 'slim' and 'haml') - If the
data-uri
attribute is specified, we could automatically addbase64
to the preload list
These should take care of most of the use cases for needing to preload a library at the moment.
from asciidoctorj.
I have been thinking about this issue and it comes to possible implementations:
- give the opportunity to users to pass as array of strings the libraries to preload from create method. The problem is that every time you change something you would require a new Asciidoctor instance. But we could provide a set method but you are passing the knowledge of which libraries should be loaded to users.
- a dynamic way, which asciidoctor-java-integration itself reads the options and execute a require operation for the required library.
something like:
if(libraryIsNotPreloadedYet("libraryName")) {
evaler.eval(runtime, "require 'libraryName'");
}
Of course if you render two files if the second one does not require libraryName, that library would be already preloaded, but I think this is not a problem. Note that runtime instance is always the same so once the libraries are preloaded, they will be there until Ruby instance become eligible for GC.
What you think?
from asciidoctorj.
I have been researching something more about how to preload libraries, it seems that defineModule method can do that work too instead of calling a Ruby script like:
if(libraryIsNotPreloadedYet("libraryName")) {
evaler.eval(runtime, "require 'libraryName'");
}
The problem is that I am not pretty sure that defineModule approach would support defining them dynamically, because at construction time I create a RubyObject (Asciidoctor) from an script and this object is reused for all future executions. So I guess it is not possible to preload libraries for that object dynamically because it is already instantiated. Maybe as first version we can give the option to user to create Asciidoctor class with static preloaded libraries, and in future we can create a refreshable method which re-instantiates a new Asciidcotor instance with the new libraries. The good news is that I think it won't affect the performance because Ruby environment will be the same so it is already initialized.
What you think?
from asciidoctorj.
sorry defineModule cannot be used for preloading libraries because it is used for defining the module structure, not for loading them, you still need to call require anyway, defineMethod is used for calling Java from JRuby. So maybe the first approach is the best one.
from asciidoctorj.
Related Issues (20)
- included jruby version is vulnerable due to snakeyaml dependency HOT 3
- release 3.0.0-alpha.1 is gravely incompatible with earlier releases HOT 11
- 'UnsupportedOperationException' when passing immutable Map as options to 'createPhraseNode' HOT 1
- Use always latest versions in distribution HOT 3
- Ensure AsciidoctorJ version is returned always in CLI
- exception containing itself as nested exception, causing maven endless loop HOT 7
- feature request: render asciidoc to markdown HOT 3
- -s CLI option should be changed to -e to align with Asciidoctor
- Automatic-Module-Name is undefined in MANIFEST file HOT 4
- CLI should set :mkdirs option by default HOT 7
- Custom Macro HOT 1
- setContext not exposed in API HOT 1
- Include processor with all attributes resolution HOT 2
- highlight.js version 9 used by AsciiDoctorJ needs update as it is out of support HOT 2
- problem parsing latex equation to pdf or epub files HOT 3
- Invalid 'backend' attribute HOT 2
- Please clarify Preprocessor documentation HOT 9
- An error occurred when creating an instance of 'asciidoctor' while running the program on Azure Service[Web App]. HOT 2
- `Column#setWidth` is ignored HOT 3
- Unknown style for listing block: mermaid HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asciidoctorj.