From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ANNWEsb/XWOY3AAAbAwnHQ (envelope-from ) for ; Sun, 30 Oct 2022 05:38:30 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 2CguEsb/XWMmGgEA9RJhRA (envelope-from ) for ; Sun, 30 Oct 2022 05:38:30 +0100 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 DC5C038B18 for ; Sun, 30 Oct 2022 05:38:29 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1op04U-0005fZ-OU; Sun, 30 Oct 2022 00:37:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1op04S-0005dG-Ur for emacs-orgmode@gnu.org; Sun, 30 Oct 2022 00:37:17 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1op04Q-0000PM-H6 for emacs-orgmode@gnu.org; Sun, 30 Oct 2022 00:37:16 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B517B240103 for ; Sun, 30 Oct 2022 05:37:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667104631; bh=BDOVLVuEmS/1tc3Pt6q2UQ+Ze+YubvexTiztTl2h6Y0=; h=From:To:Cc:Subject:Date:From; b=l5RJ+uGIyTciX+BM4e380L6TDxVDRWgmTvhmvR12IEyXZHnpV/2g2HKQbSIoviCZS sAgyprE8pT1GfEkKMsciKvpFskgWhluWbD85eKTydD+SWUPlTe4MIqF8Q9pIKvfsmv KVZlCnIPumerHywDSsEddm1HjyG3xnWXVPjoDztG95kCpVs5sxkbh/O7arkuBSlBDg 1j2cnvyW9hhV4ydpaYcoW8SLurwXyOcXB/h5Z1EjnuIsJ2ZB9cGb2WlAvUli0gyasu Z1Tf5ke4lyNuEVTYagqJBHklg9Pubf2+4ninnYCRdMtsD0SRLAeAQvsRqpDny/13l9 BVoRaJJoQ2CLA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N0NmN0TJzz9rxK; Sun, 30 Oct 2022 05:37:07 +0100 (CET) From: Ihor Radchenko To: Michael Welle Cc: emacs-orgmode@gnu.org Subject: Re: Exporting images to different output formats In-Reply-To: <87wn8ic0ej.fsf@luisa.c0t0d0s0.de> References: <87wn8ic0ej.fsf@luisa.c0t0d0s0.de> Date: Sun, 30 Oct 2022 04:37:51 +0000 Message-ID: <87tu3m9ba8.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_MSPIKE_H2=-0.001, 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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1667104710; 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=UwApwMdWminuKDzwtMHxHJHNcxkmkeK8G+DXM8eteTI=; b=H2Py2cHW5NVq83FivwCiAVEYiCH+f8C0fQfuIryxTKQ+mXPUPALp3FkPBXJuDkIttl/eJZ jJ7RzgA1wWtWorWdvunicCK2Atm++zrhnliLb9XhdlDF8HpP72mFjodjxUqDuQHIdVP5yZ zgM15FUODvybbkGXBUfd4aU68JecywVxwGIqb3bPicSDGuKtYBCW/Z8qvlbTz/sNOmWSbp Cg8VTZzbOm35iTL13qdoy8jfQr4kPIr6zfEK6ewXKr0QLC8Igjjxjiv/YwEab4mV+kYjic dP7bIws/Yth6xG06BMQRkHdpDgkB0ATHpznxhHzmZx4AG1GuwO4k1LnKVrKKCg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1667104710; a=rsa-sha256; cv=none; b=JyjDs+3r+PDgePtjOVvXHK76GerBf2DamrAnbbRq0if+9i+FnuDgmZDlaw1HGrgvSRNCcE Xpm8p3VSDmoi/kUiaf9HpxMbkPHH6RYFrDBfVJPfcv6t8NGmRGRWHfDhRm/Db0CCbAtHmJ lzvkkazm8EX8iJdB+op/apkZRFXWtzTy+76XFa3LF11dHF5MntvpbQGRINYrR24b3RaON4 sRutmgn8yFWcF+SHkLZcnibhRtJ+jKqTVDAKhe9i0kPY+NipgAL+qcWWzv3fg9Jtvi08DT yLXKEfQxX6gMGKECf2l4vXrT7QmKPRcZmgvr7bjHaD519rB4b0mA3N8E0u8qMg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=l5RJ+uGI; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.44 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=l5RJ+uGI; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: DC5C038B18 X-Spam-Score: -3.44 X-Migadu-Scanner: scn1.migadu.com X-TUID: Khvx96m19Al4 Michael Welle writes: > I want to export to different output formats. Trouble is the way ox-gfm > exports images. So I thought, hm, why not utilise macros to abstract away > the differences. Well, that escalated quickly: > > #+macro: img_gfm (eval (concat "#+begin_export md\n![img](" $1 " \"" $2 "\")\n*Abb.: " $2 "* (Quelle: " $3 ")\n#+end_export")) > > #+macro: img_latex (eval "foobar") > > # Image export for Github flavoured markdown > # $1 path to image > # $2 caption > # $3 source > #+macro: img (eval (cl-case org-export-current-backend ('gfm (concat "{{{img_gfm(" $1 "," $2 "," $3")}}}")) ('latex "{{{img_latex}}}") (t "barfoo"))) > > > {{{img(./foo, foo, barfoo)}}} > > That kind of works (and breaks if I want commas in the caption) Re: commas. See 13.5 Macro Replacement (1) Since commas separate the arguments, commas within arguments have to be escaped with the backslash character. So only those backslash characters before a comma need escaping with another backslash character. > , but is > ugly as... and doesn't get better if I implement the other output formats. Agree. The proper way to implement this is special blocks + custom export filter that will take care about backend selection. Also, see https://list.orgmode.org/orgmode/87y1yr9gbl.fsf@gmail.com/ referring to https://github.com/alhassy/org-special-block-extras/ > Maybe syntax like @@latex: ...@@ would help. But no, I think that is > defined in the specific backends, not as a general mechanism. You can have multiple export blocks---one for each backend. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at