From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id QKSrBuw2f2RPJQEASxT56A (envelope-from ) for ; Tue, 06 Jun 2023 15:38:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IOhpBuw2f2STVQAAauVa8A (envelope-from ) for ; Tue, 06 Jun 2023 15:38:52 +0200 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 8E7003E105 for ; Tue, 6 Jun 2023 15:38:51 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6Wsa-0000X4-Vx; Tue, 06 Jun 2023 09:37:45 -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 1q6WsY-0000Wr-PP for emacs-orgmode@gnu.org; Tue, 06 Jun 2023 09:37:43 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6WsW-00064i-4l for emacs-orgmode@gnu.org; Tue, 06 Jun 2023 09:37:42 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id C6C8A240027 for ; Tue, 6 Jun 2023 15:37:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686058656; bh=bm1wtmX+M3pLm+3Z/A3uwQVzsWTLEezld3YdFp/JYlY=; h=MIME-Version:Content-Transfer-Encoding:Date:From:To:Cc:Subject: Message-ID:From; b=SVtuk0KPTXi6EqzMsyKTq6nJUGNZvothQZDJv8u9WBUA2kQ5TAMX+lK3d9+7YHh6k NHAVvW3D1QOkAD0JgHxfm8Uwt5m6edxOUms/kaQNGdIGMeI1qOknOAFb4xSv8fSbfy kK/eI2GI+a9oQ2b9mFw5DM/H+ZypD1pf2v3dyhlOml8sHs71ZTVxv/0rn5S5Y6lf0M GEFjGicabzitkxUabpUz7dgypD3Ujb4Ckge7Bl8nCL5E40ambYIix9jpjhfgj/54OM 1YZHHs7Xi5poyjx8zA+Dtyys/LkbJ75ToZTx2J99X4h9mtrV7pMJ3oatT2I2+2m/WJ 1QuZkNCelMKHw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QbBNv6ypLz6tn4; Tue, 6 Jun 2023 15:37:35 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 06 Jun 2023 13:37:35 +0000 From: gerard.vermeulen@posteo.net To: Christian Moe Cc: emacs-orgmode@gnu.org, Timothy , Ihor Radchenko Subject: Re: [PATCH] ox-html.el: add option to embed SVG for CSS support in SVG In-Reply-To: <87fs74j4la.fsf@christianmoe.com> References: <871qip3u90.fsf@localhost> <87fs74j4la.fsf@christianmoe.com> Message-ID: <65d386e8c274e9703b80f2a2fefbcb7f@posteo.net> Received-SPF: pass client-ip=185.67.36.65; envelope-from=gerard.vermeulen@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1686058731; a=rsa-sha256; cv=none; b=hkER2NPMa105zxWLFXTD2l6Rnk23uXNV+JPZxISK9WHa/sFqsaZZSa49iEof6Ykhub17Ft 8i6AXpqMqnMTtTIOPNp/MoxWbMy1xs3kCdhu61CoPvtZjAmz2ZNM/QXEYz16cpuuc27P/S f9AGr0rbDiwxio7PG8uEHHDInlHb+pSxqWK0liXrjqnEH+apuuP1Ppv0eVa2wMs3tnNJEc U34DD2Yepmp695xQe9YaOOju5atriMwoewOoHh5YqOUZUiXNG440VJFJkoQ66qsOSNNHH/ LfQm4C9OuWoqDDmMg2W0YUEYvKsYZ5NWO+yQv65qeU1sRMypzVWCW6MZk28YZQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=SVtuk0KP; 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1686058731; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=rGobJpdo3Qlji9+LmZKyrtoZhbHgDPNCht1H2bD+Rbk=; b=fGv8B7f4TOYEvJKkeGIqJ2bYZZJfr/47uph2aw0pj2SVboww1ixSxy3FJMn74AKlYHf+88 nzchZB4vsZebuol5nT0nDmsrQkAbVDGqfGReHJ3MU8XqFQ3oIPYWJCX7SdmqoJKhgvnIII N3uus4wEETfySi+Uin9lxAbgXYVqCJQL5UrkX9j70BtRfF9m1nsuwrxmEO1x6Sgh7NLFrD i4EuDWXCAq+01vlRGE3U4eA+s+wGfZoojOVsit7ejfPGQi0TICLxOkvP0Cn8ZdDiVKVtRf ahxMS/Twc6ROuHYPvl9/tvcml3PQTzumS/Lo99sL9N7IlTOM0XqpnxhdsZ/qCQ== Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=SVtuk0KP; 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-Scanner: scn0.migadu.com X-Migadu-Spam-Score: -7.95 X-Spam-Score: -7.95 X-Migadu-Queue-Id: 8E7003E105 X-TUID: nhnmv3vG5tbZ On 06.06.2023 11:57, Christian Moe wrote: > Hi, > > I think there's a better approach. Tl;dr: > > - A better way to have active CSS in SVG images is to link to the > external SVG file with the rather than tag, as we used > to. > > - Without patching Org, you can embed an external SVG file as an SVG > island in Org HTML export simply by using #+INCLUDE. > > Details: > > 1) Embedded SVG is not the only way to have active CSS etc. in SVG > images. Linking to an external SVG file with an OBJECT element instead > of IMG should work fine (tested in Firefox). You can test this by > exporting Gerard's mwe.org example and editing the mwe.html to replace > > : img src="./doc8.svg" > > with > > : object type="image/svg+xml" data="./doc8.svg" Indeed, the flower works after the replacement but the caption disappears. I do not understand why, because the caption is still present in the HTML. > > Org used to use OBJECT for SVG years ago, but switched to IMG at some > point. I'm not quite sure when or why that happened (forgive me for not > doing an exhaustive search of the archive or delving into the git > record). But I think perhaps the reason was this thread, > > > https://lists.gnu.org/archive/html/emacs-orgmode/2016-07/msg00380.html > > where the issue was easy scaling, and that Jarmo Hurri's patch > switching > to IMG came to be applied at some point, even though Jarmo and I agreed > that adding a common CLASS="svgfig" attribute to OBJECT would solve his > issue, see this thread: > > > https://lists.gnu.org/archive/html/emacs-orgmode/2016-07/msg00410.html > > I continue to think that OBJECT with an .svgfig class as default (or a > setting to give the user a choice between IMG and OBJECT) is the best > solution. > > 2) You can actually embed an SVG island in Org HTML export simply by > using #+INCLUDE. To try this, add the following line to Gerard's > mwe.org: > > : #+INCLUDE: "./doc8.svg" export html > > The exported HTML should now show the black flower from Gerard's > minimal > non-working example plus a working flower. Indeed, the flower works, but the caption disappears because Org does not recognize the "#+INCLUDE ..." as a link, the caption does not show up in the HTML. Is there an easy solution for this issue. > > (Some SVG files may start with an XML declaration; if the XML > declaration is on a separate first line, you can just skip it by adding > =:lines "2-"= to the #+INCLUDE instruction.) > > Yours, > Christian Thanks -- Gerard > > Ihor Radchenko writes: > >> gerard.vermeulen@posteo.net writes: >> >>> I have been trying to export SVG images having links to CSS from Org >>> to >>> HTML >>> and I have found that the this CSS is not active in Firefox (only >>> browser I tried). >>> >>> I have found that the CCS is only active under two conditions: >>> 1. The HTML page should manage the CSS that the SVG image links to. >>> 2. The SVG image should be embedded in the HTML page. >> >> CCing Timothy, the maintainer. >> >> Also, does the above mean that Firefox does not support custom CSS >> user >> stylesheets? What am I missing? >> >>> I wrote an ox-html derived export backend to embed SVG images: >>> https://forge.chapril.org/gav451/emacs.d/src/branch/main/site-lisp/ox-my-html/ox-my-html.el >>> and merged the SVG embedding functionality into ox-html.el leading to >>> the >>> attached patch. >> >> Thanks! I will provide high-level comments from general ox.el >> perspective. >> >>> + (:html-embed-svg-excludes "HTML_EMBED_SVG_EXCLUDES" nil >>> + org-html-embed-svg-excludes split) >>> + (:html-embed-svg-includes "HTML_EMBED_SVG_INCLUDES" nil >>> + org-html-embed-svg-includes split) >> >> This is awkward. To do per-image export adjustments, we usually use >> export attributes (#+ATTR_HTML: ...). And why "split"? >> >>> + (:with-html-svg-embedding nil "html-embed-svg" >>> org-html-embed-svg) >> >> We have :html-inline-images. Maybe better :html-embed-svg ? >> >>> +(defcustom org-html-embed-svg nil >>> ... >>> + :version "30.0" >> >> We do not use :version tag. Please use :package-version. >> See Elisp manual section "15.1 Common Item Keywords". >> >> Also, maybe instead of t/nil boolean values here, we may allow the >> value >> to be a list of regular expressions or a string representing regular >> expression. This will allow what you are trying to do with >> HTML_EMBED_SVG_INCLUDES. The list elements might also be (not "..."), >> replicating HTML_EMBED_SVG_EXLCUDES. >> >> Even more generally, we may turn this into HTML_EMBED_IMAGES and embed >> all the images (possibly filtered by regexp). This will be slightly >> beyond the scope of this patch though. >> >>> +(defun org-html--embed-svg-p (link path info) >>> + "Check whether LINK and INFO specify to embed the SVG file named >>> PATH. >>> +LINK must have no contents and link to an SVG file. INFO may >>> contain >>> +lists of SVG files to include in and/or to exclude from embedding." >>> + (and (not (org-element-contents link)) >> >> Please use `org-export-inline-image-p'. >> >>> +(defun org-html-svg-contents (path) >>> + "Return the SVG contents of the file named PATH." >>> + (with-temp-buffer >>> + (insert-file-contents path) >>> + ;; Delete text preceding something starting as an SVG root >>> element. >>> + ;; The intent is to remove XML declarations (and XML comments). >>> + ;; This breaks in case of a preceding XML comment with >> inside >>> + ;; or a preceding XML element with an SVG element inside. >>> + ;; See https://emacs.stackexchange.com/a/57433 for the original >>> code. >> >> But the original code is different, no?