From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gITaNChqXGGgRQAAgWs5BA (envelope-from ) for ; Tue, 05 Oct 2021 17:07:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id UIZ2MChqXGEAZwAAbx9fmQ (envelope-from ) for ; Tue, 05 Oct 2021 15:07:20 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 76059E32E for ; Tue, 5 Oct 2021 17:07:20 +0200 (CEST) Received: from localhost ([::1]:58414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXm2J-0005ws-Gf for larch@yhetil.org; Tue, 05 Oct 2021 11:07:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXlcO-0002Rx-PI for emacs-orgmode@gnu.org; Tue, 05 Oct 2021 10:40:32 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]:37757) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mXlcL-0000ne-1w for emacs-orgmode@gnu.org; Tue, 05 Oct 2021 10:40:32 -0400 Received: by mail-lf1-x134.google.com with SMTP id i4so88062510lfv.4 for ; Tue, 05 Oct 2021 07:40:26 -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=2tDkg4EOpadX7Jm8WMrzIFbHUVt+nliit7OeJi4eHkg=; b=iOrLapezJd+iKp266eVWHHmYN0VK4B74J/T6HxD6+2Ztb3vMn0so4WJswe4kFxTBZw AzLmREg9vMgOV6yTZnjcRTjSF0sglZMBTCDS2qwVcemqdh7XPvgovxoneLAO0zAHwbbp TmRtMlgDFZq1MGhUAz6Hzz1KfdCNXjpxDhgQSWyPQoTjITMBAAFP1JjN46oTfsANBySG oFRlqOMdPP1SbEuI8Cb7Kr8u10/kuz4kGTAAUuGEFORP0mHmITnAQsr8K8xOqjBnY5Mq pwaEHnWLqvN8pFbKZmz+4mau2RstQWZ7rKjai5+cRxhAB89TJEGkI7xMuPiIlHKLpuSt YkFQ== 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=2tDkg4EOpadX7Jm8WMrzIFbHUVt+nliit7OeJi4eHkg=; b=OBpNC9PVIFcSLu35PdwMlqiimkxQA1WXuyNfRyy7E/bvZwN29AbzbWSCBF4CP5vJ+y qRrT7mGbN2CapEDawGOATXhX3f3xjAheHj9T2iIA5nZarcpUttRT/qVmeGeAmVucEd/2 HGo+4lYGHePf+Phgz+PFgdiLOYdAkiHzz9zvrupg009kaHWVGBiIS/szr1BfvTWFlAKq jhqFSzHL7biiJOsczeRjCN/ALNVBZUCa6qu64yJNYKpLOtIuMtXxv8Kgz6gtWrNljFfS 3Z840BrXbsDNWpO1vvG7KCpqSN1C73XVev/ce6kth+zk0Z4AbOSPigmdk3Aef1VJ79O/ 529A== X-Gm-Message-State: AOAM533tmrpAAvC1vS5TncaX2m8IXhQnTsHy2P2lDCod/9CqyrdMGrjK 2IGmc6Af/5TF/BvA13v9BHxb275U8dvH+2BL6+U= X-Google-Smtp-Source: ABdhPJwLRsrofhfq64ZfmXkSMyUSCCeTe0SjofP0OeLCorD2NZJBNUV6Qd4Wc3FXJdy58gEdfp1pJEPRppPskqFOwD0= X-Received: by 2002:a19:4f05:: with SMTP id d5mr3935736lfb.672.1633444823634; Tue, 05 Oct 2021 07:40:23 -0700 (PDT) MIME-Version: 1.0 References: <87wnmtb2sb.fsf@localhost> <87o884buwf.fsf@localhost> In-Reply-To: <87o884buwf.fsf@localhost> From: Jason Ross Date: Tue, 5 Oct 2021 07:40:12 -0700 Message-ID: Subject: Re: Best way to include METAPOST in ConTeXt exporter To: Ihor Radchenko Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=jasonross1024@gmail.com; helo=mail-lf1-x134.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633446440; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=2tDkg4EOpadX7Jm8WMrzIFbHUVt+nliit7OeJi4eHkg=; b=XRU2RyqdAgN994t1WF1POpr7ctufg0AP/gzI943zMeF+S16K0VgRZnW5FImaHhgOoymF1f c/fLMUh+UgpJx+a/0mVc7VOvvgERdz6b760wW593zCEjfC2wKaRaUmyEY8cGAsAhrFt9mG xuGxAnWvHiR/YLYYw1wejEotdYHpfGEIu2EvyH3NaX9NK0FbjAL1G3U5SHj+0MtbQ6KJeZ Dskf/bZYAyGvhuJn/xFuT6D92fOG7MjvZWERBaR0UkWVSsqKDbIxB/wYCSRRHsem0/jKdN KD8KbqGqfI0Js9NRCSKK8rUS4RU6vgCkT7dp2QdHCfXPT1nO4abE2BiHbr4yyg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633446440; a=rsa-sha256; cv=none; b=QimcamKWw1hVhS9JBxnlQE30SdTemQiUybF7WcrGz+w40DrlEr9GDNjAmYisA1mNf/gij5 TLBGPOesVu29ftchhqjkvE4AQTwuiAmmWz+eFvhIQkixY1U44awTi1G/SbSALCkykdL16A Ioe2KTox/Pfxa5oV5l9g7GGxh+bRrsKey90cMIFC6torbOTK/GmDbUI7QtNqzpFmhbR/NY 5j5H0qxYSj3cdUjqkugA5StLNO6g7r6nf5UFK6suc9VypcvQ+RgAzmvHt5bY1YKQFm20se aZXYoMGm3BNnBn9By6f0i87kmWBRsEoHgW3sVQ15TOtk0ByIfJiLlzqRLFe9ag== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iOrLapez; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -4.01 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=iOrLapez; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 76059E32E X-Spam-Score: -4.01 X-Migadu-Scanner: scn1.migadu.com X-TUID: n/p7sGMBIujH (Apologies to Ihor who I already replied to without cc'ing the list) ======================================================= > If you are in control of the export backend, you can directly process > the metapost source blocks during export and ignore/filter their output > as needed. This is definitely possible, but I don't want to commit to bypassing the entire Org Babel system right now. I will explore this a bit. > Or you can use "raw" results by default and format everything as you > wish in your Org Babel module programatically. I'm not sure I understand this yet. Would this emit METAPOST code to the Org buffer? Ideally, I'd like to emit METAPOST code if the backend is `context`, otherwise, emit a file. > If above is not sufficient, you can install global export filters that > can transform the metapost blocks/source blocks/their results as you > need in other export backends. This sounds like it might be a good solution. Is it possible to have an export filter that changes the header arguments of a source block before Org Babel sees them? If so, ox-context could change all METAPOST source block header arguments to give raw results wrapped in appropriate tags. Also, I'm still curious if there's a better way to add #+CAPTION and #+NAME tags to images generated by source blocks (in any context). It would be extremely handy to reference figures generated with matplotlib throughout the document, not just METAPOST drawings. Thanks, Jason On Mon, Oct 4, 2021 at 9:44 AM Ihor Radchenko wrote: > > Jason Ross writes: > > > I had considered using special blocks; they match my mental model the best. > > However, they don't provide any support for syntax highlighting or opening > > the block in a new major mode buffer. I'm not sure if it's worth giving up > > language features in order to use the block that's most intuitive to users. > > > > I'm also considering writing an Org Babel module for METAPOST. This could > > allow METAPOST figures to be included with any export backend. However, > > if I go this route, there are still some challenges: > > If you are in control of the export backend, you can directly process > the metapost source blocks during export and ignore/filter their output > as needed. > > > #+MACRO: conditional-header (eval (when (not (eq > > org-export-current-backend 'context)) (concat "#+HEADER: :results > > file :file " $1))) > > > #+BEGIN_SRC metapost :results drawer :post > > wrap_metapost(name="my-name", caption="my-caption", data=*this*) > > Or you can use "raw" results by default and format everything as you > wish in your Org Babel module programatically. > > If above is not sufficient, you can install global export filters that > can transform the metapost blocks/source blocks/their results as you > need in other export backends. > > Best, > Ihor