From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/115477 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rik Kabel via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Set up external figure for particular image type Date: Tue, 12 Jul 2022 15:01:11 -0400 Message-ID: <995e8fc7-b8ea-3d87-92e8-b2dd8aa8f1e4@rik.users.panix.com> References: <545a6de4-c8a6-b97f-7196-a4000bbdc65f@fiee.net> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4294093586066342417==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38035"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.0.2 Cc: Rik Kabel To: ntg-context@ntg.nl Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 12 21:17:37 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oBLO4-0009XQ-QN for gctc-ntg-context-518@m.gmane-mx.org; Tue, 12 Jul 2022 21:17:36 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id CF5B32A3AE5; Tue, 12 Jul 2022 21:17:03 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b8OTGelG0DNP; Tue, 12 Jul 2022 21:17:01 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 0B4122A3AEC; Tue, 12 Jul 2022 21:17:01 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 9C7DE2A3AE4 for ; Tue, 12 Jul 2022 21:16:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YzsBpnSSJqNe for ; Tue, 12 Jul 2022 21:16:56 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=166.84.1.75; helo=l2mail1.panix.com; envelope-from=context@rik.users.panix.com; receiver= X-Greylist: delayed 942 seconds by postgrey-1.36 at zapf.ntg.nl; Tue, 12 Jul 2022 21:16:55 CEST Original-Received: from l2mail1.panix.com (l2mail1.panix.com [166.84.1.75]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 32231163 for ; Tue, 12 Jul 2022 21:16:55 +0200 (CEST) Original-Received: from mailbackend.panix.com (mailbackend.panix.com [166.84.1.89]) by l2mail1.panix.com (Postfix) with ESMTPS id 4Lj98B4n22zDTX for ; Tue, 12 Jul 2022 15:01:14 -0400 (EDT) Original-Received: from [192.168.1.106] (cpe-69-204-136-231.nycap.res.rr.com [69.204.136.231]) by mailbackend.panix.com (Postfix) with ESMTPSA id 4Lj9873zlzzRRK for ; Tue, 12 Jul 2022 15:01:11 -0400 (EDT) Content-Language: en-US In-Reply-To: X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:115477 Archived-At: This is a multi-part message in MIME format. --===============4294093586066342417== Content-Type: multipart/alternative; boundary="------------08fFz3SL0afwntJ4lhT0LvTn" Content-Language: en-US This is a multi-part message in MIME format. --------------08fFz3SL0afwntJ4lhT0LvTn Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 ) -- Rik --------------08fFz3SL0afwntJ4lhT0LvTn Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


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

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)

--
Rik


--------------08fFz3SL0afwntJ4lhT0LvTn-- --===============4294093586066342417== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cHM6Ly93d3cubnRnLm5sL21haWxtYW4v bGlzdGluZm8vbnRnLWNvbnRleHQKd2VicGFnZSAgOiBodHRwczovL3d3dy5wcmFnbWEtYWRlLm5s IC8gaHR0cDovL2NvbnRleHQuYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHBzOi8vYml0YnVja2V0 Lm9yZy9waGcvY29udGV4dC1taXJyb3IvY29tbWl0cy8Kd2lraSAgICAgOiBodHRwczovL2NvbnRl eHRnYXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============4294093586066342417==--