Re: [tex4ht] How to \includegraphics using absolute path with tex4ht?

2023-10-09 Thread Michal Hoftich
Hi Nasser,

you are not using the copy_images extension. You cannot select make4ht
extension using TeX4ht options as in "mathjax,htm,nostyle,copy_image".
You need to add it to the -f option of make4ht. So the correct call
is:

$ make4ht -ulm default -f html5+copy_images foo.tex "mathjax,htm,nostyle"

To confirm that an extension is used, you can look for this message at
the beginning of the make4ht run, with the -a debug option:

[INFO]mkutils: Load extension   copy_images



Best regards,
Michal


Re: [tex4ht] How to \includegraphics using absolute path with tex4ht?

2023-10-08 Thread Nasser M. Abbasi

May be even lua can be used to automatically convert absolute path in
\includegraphics to relative one?

\includegraphics[width=textwidth]{/mnt/g/public_html/my_notes/images/my_image}

to

\includegraphics[width=textwidth]{../../my_notes/images/my_image}

This will solve all the problem.




fyi;

It seems Lua has support for finding relative path given absolute one.
Here is one link among others I found

https://stackoverflow.com/questions/13224664/how-to-convert-absolute-path-in-relative-path-using-lua

May be this will make it easy to do this conversion automatically since
make4ht is written in lua?

--Nasser



Re: [tex4ht] How to \includegraphics using absolute path with tex4ht?

2023-10-08 Thread Nasser M. Abbasi

On 10/8/2023 5:38 AM, Nasser M. Abbasi wrote:

Is there a way to make copy_images adjust the "src=" automatically
to new copy location?



I think there is a better solution to all of this. no need
to copy images and do any of this.

There are tools that automatically converts absolute path to relative path.
I only use Linux to build.

https://stackoverflow.com/questions/2564634/convert-absolute-path-into-relative-path-given-a-current-directory-using-bash
https://unix.stackexchange.com/questions/522012/how-to-convert-absolute-path-to-relative-path

and so on.

So given the example I have

\includegraphics[width=textwidth]{/mnt/g/public_html/my_notes/images/my_image}

If make4ht can detect that the image path is absolute (i.e. it starts with /),
and since current directory is always known "." then it can do

realpath --relative-to=. /mnt/g/public_html/my_notes/images/my_image

To automatically generate relative path and use that in the src= for the image
which could look now something like

  src="../../my_notes/images/my_image.svg"

as an example. I just tried it on a real path and it works

-

pwd

/mnt/g/public_html/my_notes/solving_ODE/current_version/TESTS/bad_title


realpath --relative-to=.  
/mnt/g/public_html/my_notes/solving_ODE/current_version/images/king_billingham_otto_2003.svg


../../images/king_billingham_otto_2003.svg
-

May be even lua can be used to automatically convert absolute path in
\includegraphics to relative one?

\includegraphics[width=textwidth]{/mnt/g/public_html/my_notes/images/my_image}

to

\includegraphics[width=textwidth]{../../my_notes/images/my_image}

This will solve all the problem.

Thanks,
--Nasser



Re: [tex4ht] How to \includegraphics using absolute path with tex4ht?

2023-10-08 Thread Nasser M. Abbasi

On 6/20/2023 10:21 AM, Michal Hoftich wrote:

If it works for you, I can add it to make4ht as a new extension, so it
could be then enabled from the command line.


I've added a new extension to make4ht, copy_images. It should fix this issue.

Best regards,
Michal


Thanks Michal for adding copy_images,

I am trying this option now, but I do not think it is working.
If I can explain with an example:

I have this latex file

---
\documentclass[12pt]{book}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=textwidth]{/mnt/g/public_html/my_notes/images/my_image}
\end{document}
-

Using absolute path for image. I compile using

make4ht -ulm default -d . foo.tex "mathjax,htm,nostyle,copy_images"

Where I said the output_dir is current directory. This is what  "-d ." for.

Then added "copy_images" extension.

I see that make4ht did copy the image tree to the local directory
correctly and now I have in the current directory this new tree
created

mnt/g/public_html/my_notes/images/my_image.svg

But the problem is that the HTML still has the absolute path in it!



So even though the image was copied to local directory, the
HTML itself still pointing the original image, and not
to the copied one.

Is one supposed to now edit the HTML and remove the first "/" from the src=
manually each time?

This is really a big problem for me. Since I have lots of images in
one central location and I need to include them from different places.
Using relative path is very hard to manage. An absolute path is
much easier to use.

If I copy an image to different place each time I need to include
it, then things will get out of sync very quickly and I will have
many copies all over the place.

Is there a way to make copy_images adjust the "src=" automatically
to new copy location?

Thanks
--Nasser







Re: [tex4ht] How to \includegraphics using absolute path with tex4ht?

2023-06-20 Thread Michal Hoftich
> If it works for you, I can add it to make4ht as a new extension, so it
> could be then enabled from the command line.

I've added a new extension to make4ht, copy_images. It should fix this issue.

Best regards,
Michal


Re: [tex4ht] How to \includegraphics using absolute path with tex4ht?

2023-06-19 Thread Michal Hoftich
Hi Nasser,


> 
>
> And it can't find it of course. I compile on Linux, view on windows. And on
> the server this path makes no sense.  Even if I use
>
>  src='/images/image.svg'
>
> i.e. relative to public_html/, it still does not see it on windows.
>
> How can one then use absolute path for an image when compiling to HTML?
>

TeX4ht doesn't change image paths by default, so you get absolute
paths by default. You can use a solution from this answer to copy
them: https://tex.stackexchange.com/a/656511/2891

If it works for you, I can add it to make4ht as a new extension, so it
could be then enabled from the command line.

Best regards,
Michal