asciidoctor / brackets-asciidoc-preview

Live Preview of AsciiDoc for Adobe Brackets
MIT License
51 stars 16 forks source link

Use asciidoctor extensions #33

Closed JBR69 closed 7 years ago

JBR69 commented 7 years ago

Hi,

How to use personnal asciidoctor extensions in brackets asciidoc preview ?

ty Jérôme

nerk commented 7 years ago

Right now, you can not easily do that, I think.

If your extension is written in Ruby, one way might be to create your own version of asciidoctorjs which includes your extension. Have a look at asciidoctor.js.

Then replace asciidoctor-all-min.js from the installed Brackets preview extension with you own version.

mojavelinux commented 7 years ago

Like with the Chrome extension, it might be nice to be able to specify addition JavaScript files to load in the configuration. That way, a user can transpile the Ruby-based extension to JavaScript using the Asciidoctor.js build and add it to Brackets. The Brackets plugin need not worry about how to prepare the extension, just how to load it into the runtime.

Btw, there are some pre-compiled extensions you can test at https://github.com/asciidoctor/asciidoctor.js/tree/v1.5.5-1/dist (such as the emoji inline macro).

nerk commented 7 years ago

@mojavelinux Thanks for the hint, Dan. Certainly a pretty useful feature and not difficult to add. Maybe I'll just provide an extension directory into which a user can simply drop his own extensions.

mojavelinux commented 7 years ago

That's a great idea!

JBR69 commented 7 years ago

I'm glad to see you wear an interest in my request.

I had a little trouble understanding how to regenerate asciidoctor-all-min.js with my extension (translated from Ruby to JS) and here's how I did on Windows (this may interest the other person begins like me) :

1- Install Node.js (https://nodejs.org/en/download/)

2- Get asciidoctor.js project (https://github.com/asciidoctor/asciidoctor.js)

3- In this project, copy my extension (Ruby) in the extensions-lab directory

4- Modify npm/builder.js to include my extension Ligne 300 : {source: 'build/asciidoctor-my-extension.js', destination: 'build/asciidoctor-my-extension.min.js' } Ligne 467 : opalCompileExtensions(['chrome-inline-macro', 'man-inline-macro', 'emoji-inline-macro', 'chart-block-macro', 'my-extension']);

5- Build project set MINIFY=1 node npm/build.js

6- In the build directory, copy the contents of asciidoctor-my-extension.min.js at the end of asciidoctor-all.min.js

7- Copy asciidoctor-all.min.js in C:\Users\XXX\AppData\Roaming\Brackets\extensions\user\nerk.asciidoc-preview\lib

8- Restart Brackets ==> my extension (adding new block admonition) is visible in the AD preview.

Now I look forward to developments which would put only the javascript file extension in a specific directory.

Jérôme

nerk commented 7 years ago

Cool, glad it worked for you! Extensions directory would be much more painless.

nerk commented 7 years ago

Custom extensions, CSS, and JavaScript files can now be installed (see updated README).