From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id SMY0MEwDf2RdIAAASxT56A (envelope-from ) for ; Tue, 06 Jun 2023 11:58:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id eNYwMEwDf2SwfAEA9RJhRA (envelope-from ) for ; Tue, 06 Jun 2023 11:58:36 +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 5192913C37 for ; Tue, 6 Jun 2023 11:58:36 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6TRl-0003Ry-Jv; Tue, 06 Jun 2023 05:57:49 -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 1q6TRj-0003Rg-Kz for emacs-orgmode@gnu.org; Tue, 06 Jun 2023 05:57:47 -0400 Received: from mailer-211-159.hitrost.net ([91.185.211.159]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6TRh-0008HG-8V for emacs-orgmode@gnu.org; Tue, 06 Jun 2023 05:57:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=christianmoe.com; s=x; h=Content-Type:MIME-Version:Message-ID:Date: In-reply-to:Subject:Cc:To:From:References:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JYWXy9QS/80q3Hc85KljL7oWavFpyT0N65reDZgI6b8=; b=XyrOOqdn0ohC7HsXNTiwbEAULY cypErsy7YvyF47q1bup8ikzWA4jpVIeMMQwkx+eQ/fG4mIQXsNIERq5GNqfD0hrvE9ZVSMg1syxq3 9l5OonNsmVyQt4x7PTYcE0Tebi32FjG49XGJ6N/sYYvuZOFr93AdCYuR+iUKJU/YRgSYMHmFfynhi uw3XBGkH8/cHFK2wr9zzix2urh2JZwhli0okOORp2e5TP2R1ojMn7ziEqLjrYlkG1bL9i6nslBw5Y 2Qq/uYsTTaD5ua6BSNkenNdkgdJW1N+7JNknxPs3zUce2F/1tKEk66kJSX6nB0Vnr73c+m+AbN7+F IXShf+Rg==; Received: from 92-63-16-127.dynamic.telemach.net ([92.63.16.127] helo=Tauriel) by b1.hitrost.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96-58-g4e9ed49f8) (envelope-from ) id 1q6TRK-00EaUA-0j; Tue, 06 Jun 2023 11:57:22 +0200 References: <871qip3u90.fsf@localhost> User-agent: mu4e 1.2.0; emacs 27.2 From: Christian Moe To: emacs-orgmode@gnu.org Cc: gerard.vermeulen@posteo.net, Timothy Subject: Re: [PATCH] ox-html.el: add option to embed SVG for CSS support in SVG In-reply-to: <871qip3u90.fsf@localhost> Date: Tue, 06 Jun 2023 11:57:21 +0200 Message-ID: <87fs74j4la.fsf@christianmoe.com> MIME-Version: 1.0 Content-Type: text/plain X-GeoIP: Country [IP], SI [92.63.16.127] X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-Authenticated-Id: mail@christianmoe.com Received-SPF: pass client-ip=91.185.211.159; envelope-from=mail@christianmoe.com; helo=mailer-211-159.hitrost.net X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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=1686045516; a=rsa-sha256; cv=none; b=GvMh1zuZ/H8KiafjUnUAKZAxfKbRrWqu5FxL/QV5NSFHMw52hUuKMZePa3MMoSTqj+fcZV ynViebISCatxRm2Be1vJ7wmYg9OKl+8ro3BG1RuzZ42ijFw31dcq/LtQYnUz4rDdTimCO9 DQNMMGRqm/0elHOhRQ3N0wIQoSbE8RnKOBbN16NCTbyEIlhEUQy0nnLs1ZrN/W27zbcFI6 kDWt9LhztCea6XsBoNhgUTumiWzhglK6nOA96Y78iGN5Y6CK+eDJjuJa7YTI9tFmqHGgU0 GqBWW0EGdpHEajRdbrBX6BGNuRPbBpKj59pFf9/5RFCn7OrwntAbKigZaEw5rg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=christianmoe.com header.s=x header.b=XyrOOqdn; dmarc=none; 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=1686045516; 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=JYWXy9QS/80q3Hc85KljL7oWavFpyT0N65reDZgI6b8=; b=lja31khCOaavE9TR5DfCP/pImE4Hlt5OkRK3Mm/lwCJYzUsgVawIoGHBbL+qyxVwkFk5OO A8AhtTQf+GgZ4N18fU+0ex+GQ8oDWvlQuCAO/f4364jYCmoamz3/bvYZ1Vt972N0opNqL/ FdFDMu+VwPIJbj1RZ18t17v/VBmT9uOHv6a8mfZkVWTJibP3PxPN24XoXPVxpShjH94FtY OHuwXdwIJj2N/MmmpgNBYHV2ohDm2zAMMOf3r3cODH+b7isGlfPdyESIMM1nKbSTBEScfg 9qiGWbAFJivSXTQD10BS7n4kksunqupKgk8+PTE/TkYBC0AMZiMyemu/pQiZSw== Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=christianmoe.com header.s=x header.b=XyrOOqdn; dmarc=none; 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: -3.59 X-Spam-Score: -3.59 X-Migadu-Queue-Id: 5192913C37 X-TUID: YEIyqcrcKOri 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" 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. (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 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 > + ;; 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?