That may be better, but it doesn't solve the problem. I have attached an input and output file, as well as my expected output. The difference is that in the caption, HTML tags are returned whole. But with the "raw_html" extension disabled, they should be encoded. You can see that in a paragraph HTML tags are encoded, but in the caption they are not. It seems to me like pandoc.read is using the "raw_html" extension. But I'm telling it to use PANDOC_READER_OPTIONS, which does not include that extension, as evidenced by the correct encoding of HTML in the paragraph. On Mon, Apr 4, 2022 at 12:07 PM Albert Krewinkel wrote: > > Bart 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/8735it6u1y.fsf%40zeitkraut.de > . > -- 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/CANx_DfPG-_R4hVrjxnBegGDwEE%3DzYxFB3EASZAYjCYo_975Q_A%40mail.gmail.com.