public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Making a lua filter for short captions
@ 2018-01-20  6:47 Greg Tucker-Kellogg
       [not found] ` <4be256f9-981f-4c16-92af-33bb4e3a1c40-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Tucker-Kellogg @ 2018-01-20  6:47 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1887 bytes --]

I'm trying to create a lua filter for short captions with latex output, so 
they can be used in `\listoffigures`. I have a filter that sort of kind of 
works for figures,
but it's obliterating other attributes (including the #fig needed for 
pandoc-crossref). I I'd like to fix this filter
to preserve the other attributes, and would appreciate any guidance on 
doing so.

I understand there is no current way to set attributes on tables, so that 
would have to be manual.

local utils = require 'pandoc.utils'

function Para (figure)
   if FORMAT =="latex" then
      if #figure.content == 1 and figure.content[1].t == 'Image' then
         local img = figure.content[1]
         if img.caption and img.attributes['short-caption'] then
            local short = img.attributes['short-caption']
            local long = utils.stringify(img.caption)
            return pandoc.Plain {
                     pandoc.RawInline('tex',"\\begin{figure}\n"),
                     pandoc.RawInline('tex','\\centering\n'),
                    
 pandoc.RawInline('tex',string.format("\\includegraphics{%s}\n",img.src)),
                    
 pandoc.RawInline('tex',string.format('\\caption[%s]{%s}\n',short,long)),
                     pandoc.RawInline('tex',"\\end{figure}\n")
            }
         end
      end
   end
end



-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4be256f9-981f-4c16-92af-33bb4e3a1c40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 4115 bytes --]

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

end of thread, other threads:[~2018-01-20  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-20  6:47 Making a lua filter for short captions Greg Tucker-Kellogg
     [not found] ` <4be256f9-981f-4c16-92af-33bb4e3a1c40-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2018-01-20  9:40   ` Albert Krewinkel

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).