public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Lua filters: accessing Images's 'fig:' attribute?
@ 2022-04-26 17:41 Julien Dutant
       [not found] ` <73ccd54a-b1eb-44ca-9a22-f08b63cd4757n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Dutant @ 2022-04-26 17:41 UTC (permalink / raw)
  To: pandoc-discuss


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

Hi,

Pandoc's markdown `implicit_figures` extension parses blocks consisting of 
a single image as figures. This shows up in the `native` output as `fig:` 
attribute after the source. Compare without caption:

% pandoc -t native

![](file.jpg)

[ Para [ Image ( "" , [] , [] ) [] ( "file.jpg" , "" ) ] ]
And with:

![caption](file.jpg)

[ Para
    [ Image
        ( "" , [] , [] ) [ Str "caption" ] ( "file.jpg" , "fig:" )
    ]
]
We can't look up this attribute in Lua filters. Any reason not too? Is it 
not part of the Pandoc AST, or doesn't fit neatly in current Lua types? 

I'd like my filter to be aware of whether an image is treated as figure or 
inline (e.g., to wrap the latter, but not the former, in a LaTeX center 
environment). Perhaps others need this too. Atm my best bet is to redo 
Pandoc's figure detection, i.e. (a) check if we're reading from markdown 
with the implicit_headers extension,  (b) filter Para elements looking if 
they contain only one Image with caption and if so tag it with some 
`.is-a-figure` class, and then (c) make my Image filter aware of the 
`.is-a-figure` class, and perhaps (d) clean up by removing the class. 

J

-- 
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/73ccd54a-b1eb-44ca-9a22-f08b63cd4757n%40googlegroups.com.

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

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

* Re: Lua filters: accessing Images's 'fig:' attribute?
       [not found] ` <73ccd54a-b1eb-44ca-9a22-f08b63cd4757n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-04-26 18:44   ` William Lupton
  2022-04-26 19:03   ` jmuc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
  1 sibling, 0 replies; 4+ messages in thread
From: William Lupton @ 2022-04-26 18:44 UTC (permalink / raw)
  To: pandoc-discuss

[-- Attachment #1: Type: text/plain, Size: 2379 bytes --]

I think that the 'fig:' goes into the image's title attribute?

On Tue, 26 Apr 2022 at 18:42, Julien Dutant <julien.dutant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> Hi,
>
> Pandoc's markdown `implicit_figures` extension parses blocks consisting of
> a single image as figures. This shows up in the `native` output as `fig:`
> attribute after the source. Compare without caption:
>
> % pandoc -t native
>
> ![](file.jpg)
>
> [ Para [ Image ( "" , [] , [] ) [] ( "file.jpg" , "" ) ] ]
> And with:
>
> ![caption](file.jpg)
>
> [ Para
>     [ Image
>         ( "" , [] , [] ) [ Str "caption" ] ( "file.jpg" , "fig:" )
>     ]
> ]
> We can't look up this attribute in Lua filters. Any reason not too? Is it
> not part of the Pandoc AST, or doesn't fit neatly in current Lua types?
>
> I'd like my filter to be aware of whether an image is treated as figure or
> inline (e.g., to wrap the latter, but not the former, in a LaTeX center
> environment). Perhaps others need this too. Atm my best bet is to redo
> Pandoc's figure detection, i.e. (a) check if we're reading from markdown
> with the implicit_headers extension,  (b) filter Para elements looking if
> they contain only one Image with caption and if so tag it with some
> `.is-a-figure` class, and then (c) make my Image filter aware of the
> `.is-a-figure` class, and perhaps (d) clean up by removing the class.
>
> J
>
> --
> 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/73ccd54a-b1eb-44ca-9a22-f08b63cd4757n%40googlegroups.com
> <https://groups.google.com/d/msgid/pandoc-discuss/73ccd54a-b1eb-44ca-9a22-f08b63cd4757n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAEe_xxiqzQq1PVG0fzQMP36MhMtvsATFaAtDpZkVPB7aCOm5JA%40mail.gmail.com.

[-- Attachment #2: Type: text/html, Size: 3395 bytes --]

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

* Re: Lua filters: accessing Images's 'fig:' attribute?
       [not found] ` <73ccd54a-b1eb-44ca-9a22-f08b63cd4757n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2022-04-26 18:44   ` William Lupton
@ 2022-04-26 19:03   ` jmuc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
       [not found]     ` <3e6c1960-af52-4911-aa64-f31944d0198an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  1 sibling, 1 reply; 4+ messages in thread
From: jmuc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org @ 2022-04-26 19:03 UTC (permalink / raw)
  To: pandoc-discuss


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

Some discussion on a similar issue (not showing the fig label in beamer 
while keeping the image centered) in the GitHub repo issues here 
<https://github.com/jgm/pandoc/issues/7988>.

I don't write too many filters, but isn't the "fig." bit stored in 
`img.title` for lua?
On Tuesday, 26 April 2022 at 13:41:57 UTC-4 Julien Dutant wrote:

> Hi,
>
> Pandoc's markdown `implicit_figures` extension parses blocks consisting of 
> a single image as figures. This shows up in the `native` output as `fig:` 
> attribute after the source. Compare without caption:
>
> % pandoc -t native
>
> ![](file.jpg)
>
> [ Para [ Image ( "" , [] , [] ) [] ( "file.jpg" , "" ) ] ]
> And with:
>
> ![caption](file.jpg)
>
> [ Para
>     [ Image
>         ( "" , [] , [] ) [ Str "caption" ] ( "file.jpg" , "fig:" )
>     ]
> ]
> We can't look up this attribute in Lua filters. Any reason not too? Is it 
> not part of the Pandoc AST, or doesn't fit neatly in current Lua types? 
>
> I'd like my filter to be aware of whether an image is treated as figure or 
> inline (e.g., to wrap the latter, but not the former, in a LaTeX center 
> environment). Perhaps others need this too. Atm my best bet is to redo 
> Pandoc's figure detection, i.e. (a) check if we're reading from markdown 
> with the implicit_headers extension,  (b) filter Para elements looking if 
> they contain only one Image with caption and if so tag it with some 
> `.is-a-figure` class, and then (c) make my Image filter aware of the 
> `.is-a-figure` class, and perhaps (d) clean up by removing the class. 
>
> J
>

-- 
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/3e6c1960-af52-4911-aa64-f31944d0198an%40googlegroups.com.

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

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

* Re: Lua filters: accessing Images's 'fig:' attribute?
       [not found]     ` <3e6c1960-af52-4911-aa64-f31944d0198an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2022-04-27 10:14       ` Julien Dutant
  0 siblings, 0 replies; 4+ messages in thread
From: Julien Dutant @ 2022-04-27 10:14 UTC (permalink / raw)
  To: pandoc-discuss


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

Thanks both, you're right, I missed that: this is actually the title field. 

![caption](file.jpg 'mytitle')

[ Para
    [ Image
        ( "" , [] , [] ) [ Str "caption" ] ( "file.jpg" , "fig:mytitle" )
    ]
]
in Lua, "if img.title:match('^fig:') then..." is all that's needed to check 
that it's a figure. That's very helpful and good news, thanks!

J

On Tuesday, April 26, 2022 at 8:03:41 PM UTC+1 jmuc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:

> Some discussion on a similar issue (not showing the fig label in beamer 
> while keeping the image centered) in the GitHub repo issues here 
> <https://github.com/jgm/pandoc/issues/7988>.
>
> I don't write too many filters, but isn't the "fig." bit stored in 
> `img.title` for lua?
> On Tuesday, 26 April 2022 at 13:41:57 UTC-4 Julien Dutant wrote:
>
>> Hi,
>>
>> Pandoc's markdown `implicit_figures` extension parses blocks consisting 
>> of a single image as figures. This shows up in the `native` output as 
>> `fig:` attribute after the source. Compare without caption:
>>
>> % pandoc -t native
>>
>> ![](file.jpg)
>>
>> [ Para [ Image ( "" , [] , [] ) [] ( "file.jpg" , "" ) ] ]
>> And with:
>>
>> ![caption](file.jpg)
>>
>> [ Para
>>     [ Image
>>         ( "" , [] , [] ) [ Str "caption" ] ( "file.jpg" , "fig:" )
>>     ]
>> ]
>> We can't look up this attribute in Lua filters. Any reason not too? Is it 
>> not part of the Pandoc AST, or doesn't fit neatly in current Lua types? 
>>
>> I'd like my filter to be aware of whether an image is treated as figure 
>> or inline (e.g., to wrap the latter, but not the former, in a LaTeX center 
>> environment). Perhaps others need this too. Atm my best bet is to redo 
>> Pandoc's figure detection, i.e. (a) check if we're reading from markdown 
>> with the implicit_headers extension,  (b) filter Para elements looking if 
>> they contain only one Image with caption and if so tag it with some 
>> `.is-a-figure` class, and then (c) make my Image filter aware of the 
>> `.is-a-figure` class, and perhaps (d) clean up by removing the class. 
>>
>> J
>>
>

-- 
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/8f262f86-b205-4f45-aa58-603154313e37n%40googlegroups.com.

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

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

end of thread, other threads:[~2022-04-27 10:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-26 17:41 Lua filters: accessing Images's 'fig:' attribute? Julien Dutant
     [not found] ` <73ccd54a-b1eb-44ca-9a22-f08b63cd4757n-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-04-26 18:44   ` William Lupton
2022-04-26 19:03   ` jmuc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
     [not found]     ` <3e6c1960-af52-4911-aa64-f31944d0198an-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2022-04-27 10:14       ` Julien Dutant

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