asciidoctor / asciidoctor-mathematical

An extension for Asciidoctor that converts the content of STEM blocks and inline macros using Mathematical.
MIT License
49 stars 44 forks source link

Fix relative image paths #70

Closed dalemartin closed 4 years ago

dalemartin commented 4 years ago

I have a project with a non-flat directory tree, similar to this:

basedir/images/.png basedir/content/.adoc basedir/docs/master_doc.adoc

Assume source.adoc defines the following attributes:

:imagesdir: ../../images
:imagesoutdir: {imagesdir}/equations/generated_images

I found that asciidoctor-pdf could not retrieve the asciidoctor-mathematical generated images if :imagesdir: was set, if :imagesoutdir: was not set, or both not set.

This PR allows any combination of :imagesdir: and :imagesoutdir: attributes to work even if they are empty or not in a flat directory tree. The attributes can be relative or absolute paths. If the attributes are left empty, the images are created in the same directory as the AsciiDoc source file, which I believe is the default behaviour for asciidoctor-pdf if :imagesdir: is not set.

ProgramFan commented 4 years ago

Thank you for your contribution.

bwklein commented 4 years ago

This didn't fix my issue in #83 but it did move the location of where the HTML processor was writing images to. It was putting them in the images folder of my project directory, now is it putting them in the /images folder at the root of my filesystem.

I still have the same problem where the image src attribute is wrong unless I put the generated images in the wrong location on my filesystem and depend on the PDF extension to put them in the correct spot for me.

dalemartin commented 4 years ago

@bwklein I just watched your video from #83, and a lot it is beyond me because I'm not familiar with web stuff. But I think the fundamental problem you're having is that this extension (asciidoctor-mathematical) is not meant to be called by the html5 backend, nor is it needed. The html5 backend handles latex/stem support beautifully by itself using something else, maybe MathJax or similar. You should only call this extension when running the PDF backend. I'll comment more specifically on #83.

bwklein commented 4 years ago

I use mathematical for HTML because I want optimized images (PNG) for the equations and do not want the poor page load experience when MathJax does it's thing after page load.