Open habibessoussi opened 4 years ago
Unfortunately Ruby-based extension cannot be used as-is in a JavaScript environment. You can transpile them to JavaScript using Opal or write them directly in JavaScript using Asciidoctor.js: https://asciidoctor-docs.netlify.com/asciidoctor.js/extend/extensions/
Out of curiosity which Ruby-based extension do you want to use ?
Thanks a lot for your answer. It would be for BlockMacroProcessor extension
Thanks a lot for your answer
You're welcome 😄
It would be for BlockMacroProcessor extension
Which one specifically ? I suppose that the extension already exists and is written in Ruby right ?
No they are specific ones I created through extending this Ruby class. I will try to rewrite them in JavaScript
Hello I need to activate macro in browser I have migrated Ruby BlockMacro into Javascript using Opal by following herafter guidelines https://github.com/asciidoctor/asciidoctor.js/blob/master/docs/modules/extend/pages/extensions/compile-ruby-extension.adoc
But when I add the rendered javascript to the option of "Asciidoctor.js live preview" the Live preview isn't updated with macro treatment due to error : ReferenceError : Opal not found.
Do we have to add a require or something ?
I think Opal is not found because the script is not executed in the same context, see: https://github.com/asciidoctor/asciidoctor-browser-extension/issues/220
I didn't have time to dig further on this issue... apparently there's a polyfill for Chrome...
Thanks for your quick answer. ;-) Do we have any workaround ? like including full opal.js script in extension generated script or something else ?
In Asciidoctor.js Live Preview there is no way to add custom ruby-based extension. Along with Custom attributes it would be nice to add paths to rb extension files.