From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/115475 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thangalin via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Set up external figure for particular image type Date: Tue, 12 Jul 2022 11:11:05 -0700 Message-ID: References: <545a6de4-c8a6-b97f-7196-a4000bbdc65f@fiee.net> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5838180532758353272==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4525"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Thangalin To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jul 12 20:12:16 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 1oBKMp-0000s0-Bk for gctc-ntg-context-518@m.gmane-mx.org; Tue, 12 Jul 2022 20:12:15 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8E9932802E5; Tue, 12 Jul 2022 20:11:23 +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 LYQOHHY-ttIf; Tue, 12 Jul 2022 20:11:21 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7C1842854C1; Tue, 12 Jul 2022 20:11:21 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 66606281B94 for ; Tue, 12 Jul 2022 20:11:20 +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 mjWej5UdEZiJ for ; Tue, 12 Jul 2022 20:11:18 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.167.45; helo=mail-lf1-f45.google.com; envelope-from=thangalin@gmail.com; receiver= Original-Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 4E61C2802E5 for ; Tue, 12 Jul 2022 20:11:18 +0200 (CEST) Original-Received: by mail-lf1-f45.google.com with SMTP id t1so11767157lft.8 for ; Tue, 12 Jul 2022 11:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nmpDd/v0IObOav0ey4Al3RAx9bxzX4qKb/47bTK8+NE=; b=fAilJOFjonpFs9BouFFbWDPhNyV0VnnyQv0hAvNUdQfSY/yV28Lfwv+G6lSt4Q86N1 ur/guy2AfFL7vNJj1hPAEUv0ByN17UgdnozLbqsfExIdtjCxr8Fpg+oh67wk5/AQlRBK B19qiWaos02gHPdKAg+ewwG6hqdgv8QQ9f+cbHudz1HIptcVRMKWrPZY+uGJ3L1QY9Ap XMyjN0lpNLu7uX7/BNkVcJaEz9FYd2Nwck5b/zzC8kVwwd3cL8EqlSbyUHq80tJ1Nacf I8Ha8Khuyu4DSBKH8FuZBup/GnrQJQkRWqZ85lvhMB+1rU/xqBJYn4DAhS00q2Ca3gjs 5elA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nmpDd/v0IObOav0ey4Al3RAx9bxzX4qKb/47bTK8+NE=; b=jIAYPZS4fEtQmXk36jfU2CoK1WsYJxpIwRhrM0MQU21qcvTLLqA6nOUw40FOFOjFKS K4+yzfJpWaUJy4as2vKpDMRcwyV1/lq/jp9BJYttaHmFJTI3a43h/uQ6abim4NNGT1OL 3wDeOrwFZ2hyvpkxunJoHNJ/YVJb1aKI5knIPENIbmfYhtmrf1SS5Jqcm3fiSld0COxp l0hIEaiyXDbVDSRRd63Lv/YY74eLexOPK+5lFDCNbcAIkjZejdW5mwbV7yly5Zjs5zOr wMhfDQ6FxM/RL+4WKDn6TRld7So6jBdrf6UaDVn7LC0ykT5mfb/VUMp8hda5+Zg2ylmB xUKA== X-Gm-Message-State: AJIora/xeHrMpFHOULfVD8peIhqWMszg8ntTtmA3dgAlzqPynoLKvo6/ uf5tAATXroMSBvkJuaRyJG87D41GOrUYAVpQmasVvSXV600= X-Google-Smtp-Source: AGRyM1tc+qDlNJu+cIjKSSGqJcCRSbTi/Ph1+7maeC+IvDFJrMN3Dmnkbp8zLMpEa3Tc8ljzhVN7yIt1yV82jtEyeOM= X-Received: by 2002:a05:6512:22c8:b0:488:e69b:9311 with SMTP id g8-20020a05651222c800b00488e69b9311mr15033879lfu.564.1657649476347; Tue, 12 Jul 2022 11:11:16 -0700 (PDT) In-Reply-To: <545a6de4-c8a6-b97f-7196-a4000bbdc65f@fiee.net> 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:115475 Archived-At: --===============5838180532758353272== Content-Type: multipart/alternative; boundary="000000000000332d1d05e39f9816" --000000000000332d1d05e39f9816 Content-Type: text/plain; charset="UTF-8" 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! --000000000000332d1d05e39f9816 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tha= nk 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 imag= es use the same syntax and are treated the same way. The only part that dif= fers is the file name extension (and header within the file).

One possibility would be something lik= e:
\setupexternalfigure[
    width=3D1em,
    height=3D1em,
    order=3D{svg,pdf,png,jpg},
    location=3D{local,default,global},
]

\defineexternalfigure[png][
    width=3D\textwidth,
    height=3D\textheight,
]

\unprotect

\let\old_externalfigure=
=3D\externalfigure

\tolerant\def\externalfigure[#1]#,[#2]#,[#3]{%
    \doifelseinstring{.png}{#1}{=
%
        \old_externalfigure[#1<=
/span>][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 mor= e the ConTeXt-way?

T= hanks again!
--000000000000332d1d05e39f9816-- --===============5838180532758353272== 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== --===============5838180532758353272==--