How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

egalitarian
Is there a way to do so? I want to put the html5 document in a different directory but still be able to see images.

:data-uri: is an option, but it slows down conversion and is not suitable in live preview.
Reply | Threaded
Open this post in threaded view
|

Re: How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

David Jencks
I’m curious why you would want to do this.

One way to end up with absolute paths is to specify them explicitly, perhaps using an attribute for the part up to the imagedir.

david jencks


On Feb 15, 2020, at 7:48 PM, egalitarian [via Asciidoctor :: Discussion] <[hidden email]> wrote:

Is there a way to do so?


To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

egalitarian
This is what I currently do in emacs.

(bind-key "C-x c"
          (lambda ()
            (interactive)
            (call-process "asciidoctor" nil nil nil
                          "-a" "data-uri" "-o" "/tmp/adoc-preview.html"
                          (buffer-file-name))))
(bind-key "C-x p"
          (lambda ()
            (interactive)
            (call-process "qutebrowser" nil 0 nil
                          "/tmp/adoc-preview.html")))

C-x c is mapped to converting the current file into /tmp/adoc-preview.html with data-uri.
C-x p executes "qutebrowser /tmp/adoc-preview.html".

If data-uri can be omitted, conversion would become faster. This is used for semi-automatic live preview.
Reply | Threaded
Open this post in threaded view
|

Re: How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

David Jencks
That’s a nice idea!  Do you have emacs understanding asciidoc?  Until recently I was using emacs exclusively for asciidoc, but without any syntax help.

I don’t know how to make asciidoctor generate absolute paths, but i wonder if you could symlink your imagedir to the appropriate relative location to where the preview is?

thanks
David Jencks

On Feb 15, 2020, at 9:29 PM, egalitarian [via Asciidoctor :: Discussion] <[hidden email]> wrote:

This is what I currently do in emacs.

(bind-key "C-x c"
          (lambda ()
            (interactive)
            (call-process "asciidoctor" nil nil nil
                          "-a" "data-uri" "-o" "/tmp/adoc-preview.html"
                          (buffer-file-name))))
(bind-key "C-x p"
          (lambda ()
            (interactive)
            (call-process "qutebrowser" nil 0 nil
                          "/tmp/adoc-preview.html")))

C-x c is mapped to converting the current file into /tmp/adoc-preview.html with data-uri.
C-x p executes "qutebrowser /tmp/adoc-preview.html".

If data-uri can be omitted, conversion would become faster. This is used for semi-automatic live preview.


To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

egalitarian
That would not be generalize to all asciidoc files. It needs support from ascidooctor.
Reply | Threaded
Open this post in threaded view
|

Re: How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

mojavelinux
Administrator
The only way to control the path to images out of the box is to override the imagesdir attribute. The other options are to a) copy the images when converting the document (which is what most build plugins do) or b) extend the built-in HTML converter either using templates or the API and modify the value of the src attribute.

Cheers,

-Dan

On Sun, Feb 16, 2020 at 3:28 AM egalitarian [via Asciidoctor :: Discussion] <[hidden email]> wrote:
That would not be generalize to all asciidoc files. It needs support from ascidooctor.


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: How can I convert relative image paths to absolute paths when I convert asciidoctor to html5?

egalitarian
I shall stick to data-uri attribute for now.