Filename extension changed by default when upgrading to asciidoctor 2

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Filename extension changed by default when upgrading to asciidoctor 2

dsyer
I was using asciidoctor 1.5.4 quite happily, and doing `Asciidoctor.render_file(fname, options)` with a custom backend. It worked fine and spat out `file.adoc` to `file.html` just as I needed. When upgrading to asciidoctor 2.0 I found that unless I used `:to_file => true` in the options the output didn't come to a file any more. But once I fixed that the filename is wrong because the extension is not "html". How do I change the output filename?
Reply | Threaded
Open this post in threaded view
|

Re: Filename extension changed by default when upgrading to asciidoctor 2

dsyer
Update: looks like `Asciidoctor::DEFAULT_EXTENSIONS['<backend>'] = '.html'` was what I needed, where `<backend>` is the id of the backend.
Reply | Threaded
Open this post in threaded view
|

Re: Filename extension changed by default when upgrading to asciidoctor 2

mojavelinux
Administrator
It depends on how your custom backend / converter works, but the simplest way to solve this without hacking Asciidoctor core is to set the outfilesuffix attribute. The outfilesuffix is what is used to determine what suffix to put on the output file. You can specify this attribute via the API. I'm curious to know if that solves your issue.

There's also a way for a custom backend / converter to self register an outfilesuffix. But that may be more intricate than you need.

Cheers,

-Dan

On Tue, Apr 2, 2019 at 8:35 AM dsyer [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Update: looks like `Asciidoctor::DEFAULT_EXTENSIONS['<backend>'] = '.html'` was what I needed, where `<backend>` is the id of the backend.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Filename-extension-changed-by-default-when-upgrading-to-asciidoctor-2-tp6822p6823.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Filename extension changed by default when upgrading to asciidoctor 2

mojavelinux
Administrator
I also want to point out that you can set the inherited backend now when you set the backend. This was done explicitly to deal with the situation where the basebackend (and thus outfilesuffix) cannot be guessed from the backend, which is your case.

Set the backend as follows:

backend: 'slides:html'

Then, to_file: true will work (because your custom backend will inherit from the html backend). Let me know if that works out for you.

Cheers,

-Dan

On Tue, Apr 2, 2019 at 12:31 PM mojavelinux [via Asciidoctor :: Discussion] <[hidden email]> wrote:
It depends on how your custom backend / converter works, but the simplest way to solve this without hacking Asciidoctor core is to set the outfilesuffix attribute. The outfilesuffix is what is used to determine what suffix to put on the output file. You can specify this attribute via the API. I'm curious to know if that solves your issue.

There's also a way for a custom backend / converter to self register an outfilesuffix. But that may be more intricate than you need.

Cheers,

-Dan

On Tue, Apr 2, 2019 at 8:35 AM dsyer [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Update: looks like `Asciidoctor::DEFAULT_EXTENSIONS['<backend>'] = '.html'` was what I needed, where `<backend>` is the id of the backend.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Filename-extension-changed-by-default-when-upgrading-to-asciidoctor-2-tp6822p6823.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Filename-extension-changed-by-default-when-upgrading-to-asciidoctor-2-tp6822p6824.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux