Thangalin via ntg-context schrieb am 12.07.2022 um 20:11:
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?
When you use XML as input you can add additional code to the setups block which uses \externalfigure to load the image. \setupexternalfigures [location={local,global,default}] \defineexternalfigure [jpg] [width=4cm] \defineexternalfigure [png] [width=8cm] \starttexdefinition includegraphics #1 \splitfilename{#1} \processaction [\splitofftype] [ jpg=>{\externalfigure[#1][jpg]}, png=>{\externalfigure[#1][png]}, default=>{\externalfigure[#1]}, unknown=>{\externalfigure[#1]}] \stoptexdefinition %\starttexdefinition includegraphics #1 % % \getfiguredimensions[#1] % % \processaction % [\figurefiletype] % [ jpg=>{\externalfigure[#1][jpg]}, % png=>{\externalfigure[#1][png]}, % default=>{\externalfigure[#1]}, % unknown=>{\externalfigure[#1]}] % %\stoptexdefinition \starttext \includegraphics{hacker.jpg} \includegraphics{mill.png} \includegraphics{cow.pdf} \stoptext Wolfgang