[NTG-context] Set up external figure for particular image type

Rik Kabel ConTeXt at rik.users.panix.com
Tue Jul 12 21:01:11 CEST 2022

On 2022-07-12 14:11, Thangalin via ntg-context wrote:
> Thank you for the suggestion Hraban.
> The source comes from Markdown, which is converted to XML, then 
> typeset using ConTeXt. There's no Markdown-specific mechanism to 
> relate images to a particular external figure definition, 
> unfortunately. All images use the same syntax and are treated the same 
> way. The only part that differs is the file name extension (and header 
> within the file).
> One possibility would be something like:
> |\setupexternalfigure[ width=1em, height=1em, order={svg,pdf,png,jpg}, 
> location={local,default,global}, ] \defineexternalfigure[png][ 
> width=\textwidth, height=\textheight, ] \unprotect 
> \let\old_externalfigure=\externalfigure 
> \tolerant\def\externalfigure[#1]#,[#2]#,[#3]{% 
> \doifelseinstring{.png}{#1}{% \old_externalfigure[#1][png][#2]% }{% 
> \doifelsefileexists{#1.png}{% \old_externalfigure[#1.png][png][#2]% 
> }{% \old_externalfigure[#1][#2][#3]% }% }% } \protect |
> See: https://tex.stackexchange.com/a/650221/2148
> I was wondering if there was a simpler or a solution that's more the 
> ConTeXt-way?
> Thanks again!

Assuming that Pandoc markdown is being used, you should be able to set 
class attributes on each image. You can then associate external figure 
definitions with specific classes, and process each individually. 
(Pandoc user guide, link_attributes 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220712/4b68ef55/attachment-0001.htm>

More information about the ntg-context mailing list