public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Inconsistent results of returning the original or a new Image in lua filter
@ 2020-10-30  8:31 jiewuza
       [not found] ` <m2a6w4qfmz.fsf-9Onoh4P/yGk@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: jiewuza @ 2020-10-30  8:31 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


In my markdown file, it has
```
![This is the caption](image.png)
```

And I have in my lua filter
```
function Image(img)
   return img
end
```

When converting it into latex, I get
```
\begin{figure}
\centering
\includegraphics{image.png}
\caption{This is the caption}
\end{figure}
```

And if I modify the function
```
function Image(img)
   return pandoc.Image(img.caption, img.src)
end
```

I just get:
```
\includegraphics{image.png}
```


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Inconsistent results of returning the original or a new Image in lua filter
       [not found] ` <m2a6w4qfmz.fsf-9Onoh4P/yGk@public.gmane.org>
@ 2020-10-30 16:37   ` Albert Krewinkel
  2020-10-31  1:40     ` jiewuza
  2020-10-31  1:44     ` jiewuza
  0 siblings, 2 replies; 4+ messages in thread
From: Albert Krewinkel @ 2020-10-30 16:37 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


jiewuza writes:

> In my markdown file, it has
> ```
> ![This is the caption](image.png)
> ```
>
> And I have in my lua filter
> ```
> function Image(img)
>    return img
> end
> ```
>
> When converting it into latex, I get
> ```
> \begin{figure}
> \centering
> \includegraphics{image.png}
> \caption{This is the caption}
> \end{figure}
> ```
>
> And if I modify the function
> ```
> function Image(img)
>    return pandoc.Image(img.caption, img.src)
> end
> ```
>
> I just get:
> ```
> \includegraphics{image.png}
> ```

Pandoc's writers treat images as figures iff

1. the image is the only element in a paragraph, and
2. the image's title begins with the string 'fig:'.

The modified function removes the title from the image element, so
condition 2 is no longer satisfied. The title can be passed as the third
argument to the `pandoc.Image` function, which will mark it as a figure
again:

    function Image(img)
      return pandoc.Image(img.caption, img.src, img.title)
    end

--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Inconsistent results of returning the original or a new Image in lua filter
  2020-10-30 16:37   ` Albert Krewinkel
@ 2020-10-31  1:40     ` jiewuza
  2020-10-31  1:44     ` jiewuza
  1 sibling, 0 replies; 4+ messages in thread
From: jiewuza @ 2020-10-31  1:40 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


Good to know it.
Thank you.

Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
writes:

> jiewuza writes:
>
>> In my markdown file, it has
>> ```
>> ![This is the caption](image.png)
>> ```
>>
>> And I have in my lua filter
>> ```
>> function Image(img)
>>    return img
>> end
>> ```
>>
>> When converting it into latex, I get
>> ```
>> \begin{figure}
>> \centering
>> \includegraphics{image.png}
>> \caption{This is the caption}
>> \end{figure}
>> ```
>>
>> And if I modify the function
>> ```
>> function Image(img)
>>    return pandoc.Image(img.caption, img.src)
>> end
>> ```
>>
>> I just get:
>> ```
>> \includegraphics{image.png}
>> ```
>
> Pandoc's writers treat images as figures iff
>
> 1. the image is the only element in a paragraph, and
> 2. the image's title begins with the string 'fig:'.
>
> The modified function removes the title from the image element, so
> condition 2 is no longer satisfied. The title can be passed as the third
> argument to the `pandoc.Image` function, which will mark it as a figure
> again:
>
>     function Image(img)
>       return pandoc.Image(img.caption, img.src, img.title)
>     end
>
> --
> Albert Krewinkel
> GPG: 8eed e3e2 e8c5 6f18 81fe  e836 388d c0b2 1f63 1124


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Inconsistent results of returning the original or a new Image in lua filter
  2020-10-30 16:37   ` Albert Krewinkel
  2020-10-31  1:40     ` jiewuza
@ 2020-10-31  1:44     ` jiewuza
  1 sibling, 0 replies; 4+ messages in thread
From: jiewuza @ 2020-10-31  1:44 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Albert Krewinkel <albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
writes:

>
> Pandoc's writers treat images as figures iff
>
> 1. the image is the only element in a paragraph, and
> 2. the image's title begins with the string 'fig:'.
>
> The modified function removes the title from the image element, so
> condition 2 is no longer satisfied. The title can be passed as the third
> argument to the `pandoc.Image` function, which will mark it as a figure
> again:
>
>     function Image(img)
>       return pandoc.Image(img.caption, img.src, img.title)
>     end
>

I also tried
```
function Image(img)
   print(obj.t, TableToStr(obj))
   return pandoc.Para{pandoc.Image(img.caption, img.src)}
end
```

But the image goes away from the output.

Is it because Image is inline and Para is block? But no error is reported.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-10-31  1:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30  8:31 Inconsistent results of returning the original or a new Image in lua filter jiewuza
     [not found] ` <m2a6w4qfmz.fsf-9Onoh4P/yGk@public.gmane.org>
2020-10-30 16:37   ` Albert Krewinkel
2020-10-31  1:40     ` jiewuza
2020-10-31  1:44     ` jiewuza

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).