Hello everyone.

I've decided to write a Lua filter for Pandoc on my own, something similar to scotthartley/pandoc-wrapfig with a slightly different syntax: it uses classes and attributes instead of modifying caption format.

![caption with **bold**](image.png "Image title"){#img .wrap width=3}

So far so good, but diving deeper in the details I've had some problems.

Width attribute

Quoting the manual (extension: link attributes):

The width and height attributes on images are treated specially. When used without a unit, the unit is assumed to be pixels.

and

Dimensions are converted to inches for output in page-based formats like LaTeX. [...] Use the --dpi option to specify the number of pixels per inch. The default is 96dpi.

However, PANDOC_READER_OPTIONS doesn't provide --dpi such option. I think it would be cool if Pandoc could handle it itself before calling the writers, or at least provide a conversion function within the API.

Image with attributes and formatted caption

Such syntax

![[caption]{.underline}](image.png)

produces the following output:

$ pandoc demo.md -t native
[Para [Image ("",[],[]) [Span ("",["underline"],[]) [Str "caption"]] ("image.png","fig:")]]

$ pandoc demo.md -t latex
\begin{figure}
\centering
\includegraphics{image.png}
\caption{{caption}}
\end{figure}

$ pandoc demo.md -t html5
<figure>
<img src="image.png" alt="caption" /><figcaption><span class="underline">caption</span></figcaption>
</figure>

I suppose it could be a bug, or maybe LaTeX doesn't support underline within the context of a caption. However I think some clarification is needed and the AST passed to Lua should be revised as well since it's pretty a mess:

![[caption]{.underline}](image.png)
1:
  c:
    1:
      1:
      2:
        1: underline
      3:
    2:
      1:
        c: caption

![caption](image.png)
1:
  c: caption

![*caption*](image.png)
1:
  c:
    1:
      c: caption

(*): these tables refer to el.c[2] only

Also, I couldn't find any good documentation on parameter's fields (at least for images) and it took me a couple of hours to understand it. I would add something like this to the docs:

-- Creates an image identical to the one given
function Image (el)
   
local id, classes, attrs = unpack(el.c[1])
   
local caption = el.c[2]
   
local src, title = unpack(el.c[3])

   
return pandoc.Image(caption, src, title, {id, classes, attrs})
end

Finally, this it the first filter I write (and my first experience with Lua) so I would really appreciate if the community could give me a feedback to check if I got everything right: current version is attached, thanks in advance!

I would really like to take this opportunity to thank John and all the devs for creating Pandoc: it's a unique piece of software, couldn't wish any better!

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6e09bd71-ee77-4de7-a002-953a62325234%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.