Bart <bart.hijmans-df9nrXIP1oRmR6Xm/wNWPw@public.gmane.org> writes:
> I'm trying to write a lua filter that adds captions to code blocks
> (markdown -> html). They are specified as attributes.
>
> [...]
>
> After looking around for a solution, I came up with the following that
> seemed very simple:
>
> ```lua
> {pandoc.Plain(pandoc.RawInline(
> 'html',
> pandoc.write(
> pandoc.read(
> el.attributes.caption,
> 'markdown',
> PANDOC_READER_OPTIONS
> ),
> 'html',
> PANDOC_WRITER_OPTIONS
> )
> ))}
> ```
That's a good solution, in general. Note that you can omit the
PANDOC_READER_OPTiONS and PANDOC_WRITER_OPTIONS, in which case the
default options will be used.
Even simpler would be to replace the full snippet above with
```lua
pandoc.Plain(
pandoc.utils.blocks_to_inlines(
pandoc.read(el.attributes.caption, 'markdown').blocks
)
)
```
This should give you the result you need and has the advantage of
working with any output format.
Does this solve the problem? If not, could you add a little example for
us to look at?
Cheers,
Albert
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
--
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/8735it6u1y.fsf%40zeitkraut.de.