asciidoctor-mathematical icon indicating copy to clipboard operation
asciidoctor-mathematical copied to clipboard

Inline stem macros inside AsciiDoc table cells are generated without considering to_dir

Open lmoellendorf opened this issue 5 years ago • 3 comments

Steps to Reproduce

sample.adoc

based on sample.adoc

= Precompiled Math
:math:
:stem: latexmath

== Equations in normal blocks

[latexmath]
++++
k_{n+1} = n^2 + k_n^2 - k_{n-1}
++++

Some useful text! Formula for quadratic root:

[stem]
++++
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
++++

Inline equation works too! latexmath:[a^2+b^2=c^2]. Or as stem
stem:[a^2+b^2=c^2]. Pretty nice, huh?

== Equations in table cells

Equations in asciidoc style table cells work, too!

[%header]
|===
| Demo | Contents
| Inline Equation in *Asciidoc* Cells
a|

This is an *inline* equation: latexmath:[E=m \cdot c^2].

| Block Equation in *Asciidoc* Cells
a| The following is a stem block:
[stem]
++++
a^2+b^2=c^2+d^2
++++

|===

asciidoctor invocation

pwd is /doc

asciidoctor  --destination-dir=/doc/build -a imagesdir=images -r asciidoctor-mathematical /doc/sample.adoc

Expected Result

All generated images should got into /doc/build/images

Actual Result

$ find ./ -name 'stem-*'
./images/stem-e21aaf56997f76dcc4584ad75fd32494.png
./images/stem-f5419604efe38ee8591c30c2a37fe800.png
./build/images/stem-560f2ca395ac37caca2a4729e62691d2.png
./build/images/stem-e1affc0a43f89ae2da953b789d29e42c.png
./build/images/stem-0b241139835e83278d5b9e608a543ce0.png

However, there are relative paths to images in the generated HTML for all generated images:

 $ grep 'stem-' sample.html
<img src="images/stem-560f2ca395ac37caca2a4729e62691d2.png" alt="$$k_{n+1} = n^2 + k_n^2 - k_{n-1}$$" width="125" height="14">
<img src="images/stem-0b241139835e83278d5b9e608a543ce0.png" alt="$$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$$" width="118" height="33">
<p>Inline equation works too! <span class="image"><img src="images/stem-e1affc0a43f89ae2da953b789d29e42c.png" alt="stem e1affc0a43f89ae2da953b789d29e42c" width="66" height="10"></span>. Or as stem
<span class="image"><img src="images/stem-e1affc0a43f89ae2da953b789d29e42c.png" alt="stem e1affc0a43f89ae2da953b789d29e42c" width="66" height="10"></span>. Pretty nice, huh?</p>
<p>This is an <strong>inline</strong> equation: <span class="image"><img src="images/stem-e21aaf56997f76dcc4584ad75fd32494.png" alt="stem e21aaf56997f76dcc4584ad75fd32494" width="58" height="10"></span>.</p>
<img src="images/stem-f5419604efe38ee8591c30c2a37fe800.png" alt="$$a^2+b^2=c^2+d^2$$" width="94" height="12">

Remarks

If I remove the a attribute from the table cell to test with non-adoc cells, asciidoctor fails with:

asciidoctor: FAILED: /doc/sample.adoc: Failed to load AsciiDoc document - undefined method `lines=' for #<Asciidoctor::Table::Cell:0x0000564584ebe888>
Did you mean?  lines
               lineno
  Use --trace for backtrace

This is bug #73?


I've noticed that the behavior is like expected if using asciidoctor-pdf instead of asciidoctor.

lmoellendorf avatar Apr 15 '20 16:04 lmoellendorf

Which version is used in this issue?

ProgramFan avatar Apr 18 '20 03:04 ProgramFan

asciidoctor-2.0.10 asciidoctor-pdf-1.5.3 asciidoctor-mathematical-0.3.1

lmoellendorf avatar Apr 18 '20 08:04 lmoellendorf

Is there any progress, this also bothers me

eastack avatar Oct 19 '21 06:10 eastack