Skip to content
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

Add Ruby-based extension in Asciidoctor.js Live Preview #297

Open
habibessoussi opened this issue Jul 28, 2019 · 7 comments
Open

Add Ruby-based extension in Asciidoctor.js Live Preview #297

habibessoussi opened this issue Jul 28, 2019 · 7 comments

Comments

@habibessoussi
Copy link

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.

@ggrossetie
Copy link
Member

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 ?

@habibessoussi
Copy link
Author

Thanks a lot for your answer. It would be for BlockMacroProcessor extension

@ggrossetie
Copy link
Member

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 ?

@habibessoussi
Copy link
Author

No they are specific ones I created through extending this Ruby class. I will try to rewrite them in JavaScript

@Dedeou31
Copy link

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 ?

@ggrossetie
Copy link
Member

I think Opal is not found because the script is not executed in the same context, see: #220

I didn't have time to dig further on this issue... apparently there's a polyfill for Chrome...

@Dedeou31
Copy link

Thanks for your quick answer. ;-)
Do we have any workaround ? like including full opal.js script in extension generated script or something else ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants