public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* pandoc.read and pandoc.write using unspecified extensions. Adding captions to code blocks.
@ 2022-04-04  9:34 Bart
       [not found] ` <1302c732-b7fe-4339-8234-99b761f47296n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Bart @ 2022-04-04  9:34 UTC (permalink / raw)
  To: pandoc-discuss


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

Hello,

I'm trying to write a lua filter that adds captions to code blocks 
(markdown -> html). They are specified as attributes. At first I added the 
following:

`{pandoc.Para(codeBlock.attributes.caption)}`

which worked, but we found that the caption is a raw string, and not 
compiled from markdown to html like table captions are. So a caption like 
`**bold**` did not appear in bold.

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
     )
))}
```
It certainly seems like that is supposed read the caption as a markdown 
document and then write it as html using the same options as the original 
pandoc run. However, we have disabled the raw_html extension for the main 
document. It is not listed in either PANDOC_READER_OPTIONS.extensions or 
PANDOC_WRITER_OPTIONS.extensions. But html tags in the caption are not 
encoded, even though they are everywhere else.

Am I doing something wrong here? Is there a way to disable the extension? 
Is there a simpler way to add bold, italics, strikethrough and inline code 
to these captions?

-- 
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/1302c732-b7fe-4339-8234-99b761f47296n%40googlegroups.com.

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

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

end of thread, other threads:[~2022-04-04 18:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04  9:34 pandoc.read and pandoc.write using unspecified extensions. Adding captions to code blocks Bart
     [not found] ` <1302c732-b7fe-4339-8234-99b761f47296n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-04-04  9:55   ` Albert Krewinkel
     [not found]     ` <8735it6u1y.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2022-04-04 14:26       ` Bart Hijmans
     [not found]         ` <CANx_DfPG-_R4hVrjxnBegGDwEE=zYxFB3EASZAYjCYo_975Q_A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2022-04-04 16:07           ` Albert Krewinkel
     [not found]             ` <87tub86d62.fsf-9EawChwDxG8hFhg+JK9F0w@public.gmane.org>
2022-04-04 18:11               ` Bart Hijmans

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