public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Lua filter process LaTeX
@ 2020-10-26 10:28 Thomas Hodgson
       [not found] ` <021778da-effc-47ab-b69b-1d33e16a041fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Hodgson @ 2020-10-26 10:28 UTC (permalink / raw)
  To: pandoc-discuss


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

I have been learning how to write filters with Lua. I started with the 
tikz.lua example, and changed it to search for any figure. I want to put 
captions in the alt text of the images. So, I added this:

```
local caption = string.match(el.text, "\\caption{(.-)}")
        if caption then
            return pandoc.Plain({pandoc.Image({pandoc.Str(caption)}, 
fname)})
```

That works, but it turns the raw LaTeX into a string, and my regex only 
goes as far as the last bracket; this is a regex issue.. So, I get things 
like this as alt text:

`foo' \emph{bar

Is there a way to have the filter turn that LaTeX into Pandoc's native 
format? I tried to think about pandoc.read, but didn't get very far.

Thanks.

Tom

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/021778da-effc-47ab-b69b-1d33e16a041fn%40googlegroups.com.

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

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

end of thread, other threads:[~2020-11-20 22:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 10:28 Lua filter process LaTeX Thomas Hodgson
     [not found] ` <021778da-effc-47ab-b69b-1d33e16a041fn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-26 11:44   ` Thomas Hodgson
     [not found]     ` <59cbbd11-ca9d-4334-a348-92277bb459c2n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-26 12:41       ` William Lupton
     [not found]         ` <CAEe_xxi3KVqos4O4Q4Ng1vx=WB9wT8dV+-z1DMq7FsxGVRkF3w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2020-10-26 15:52           ` Thomas Hodgson
     [not found]             ` <09ac0613-ca74-459f-8cd1-e09c276308dbn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-30 10:32               ` Thomas Hodgson
     [not found]                 ` <ca58cb60-eda3-4ae0-86b6-b6c27aba7c3bn-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-10-30 16:11                   ` Albert Krewinkel
     [not found]                     ` <87pn4zlmna.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2020-11-20 22:21                       ` Thomas Hodgson

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