asciidoctor / asciidoctor-browser-extension

:white_circle: An extension for web browsers that converts AsciiDoc files to HTML using Asciidoctor.js.
https://chrome.google.com/webstore/detail/asciidoctorjs-live-previe/iaalpfgpbocpdfblpnhhgllgbdbchmia
MIT License
218 stars 50 forks source link

how to Add custom JavaScript - before the document has been rendered ? #639

Closed qwertysk closed 2 years ago

qwertysk commented 2 years ago

Pls, what is the correct way to do that ?

I want to replace/remove some parts using regex - before adoc is rendered - something like preprocessor ...

image

image

ggrossetie commented 2 years ago

Hello,

It's currently not possible to register Asciidoctor.js extension since the code is running in the background script. This feature will run JavaScript in the context of web pages (client-side) before or after the HTML document has been rendered.

As far as I know, it's not possible to load user-provided code in the background script/context... one idea (I just had) would be to send a message to the background script/context and use eval to load the code but that's not pretty and potentially unsecure/harmful!

If you want to track progress on this new feature, please open a formal proposal for this feature.

In the future, please ask usage questions in the project chat at chat.asciidoctor.org. We don't use the issue tracker as a support forum.