From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +FcdLsrMRmOnjgAAbAwnHQ (envelope-from ) for ; Wed, 12 Oct 2022 16:18:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id sIwrLsrMRmN3BQAA9RJhRA (envelope-from ) for ; Wed, 12 Oct 2022 16:18:50 +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 84D60278D3 for ; Wed, 12 Oct 2022 16:18:50 +0200 (CEST) Received: from localhost ([::1]:38216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oicZL-0008PM-8y for larch@yhetil.org; Wed, 12 Oct 2022 10:18:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oicY8-0008Nr-Ep for emacs-orgmode@gnu.org; Wed, 12 Oct 2022 10:17:32 -0400 Received: from smtp.lrde.epita.fr ([91.243.117.225]:42152) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oicY6-0003NF-7H for emacs-orgmode@gnu.org; Wed, 12 Oct 2022 10:17:32 -0400 Received: from goulash (unknown [192.168.101.25]) by smtp.lrde.epita.fr (Postfix) with ESMTPSA id 2ACF9430BD; Wed, 12 Oct 2022 16:17:13 +0200 (CEST) From: Alexandre Duret-Lutz To: emacs-orgmode@gnu.org Subject: Org 9.5 broke the rendering of my SVG images cc: tec@tecosaur.com Date: Wed, 12 Oct 2022 16:17:16 +0200 Message-ID: <87o7uhp1n7.fsf@lrde.epita.fr> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=91.243.117.225; envelope-from=adl@lrde.epita.fr; helo=smtp.lrde.epita.fr X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" 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=1665584330; 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:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=yHfVnOVIzKPE4Jc7Vcjf4SKVbk9Ga/DsRLihCGJPWRI=; b=KfUZH6qaP39/i2lM2sWZMPKEgOcBfKrD/U6gLm8Dv/C0gsYR6TQn87ZI5/kGcyneeUCca5 3F2KzXO7UmT17eDaxC3X/0emPpWzRIcm8DLgJRZ/5795IVRwuSZt927p0h+L59Z4fCgqTw A9xW/e3nDjoAEUgPQ1pxcTSmMKSTHPAfUKMZQV02TQtzdUxzxRjUT0u7EWAa58hEFAY5q2 IdEJa2ZGa2yLBJr2PCqwCf0lCXNOj/iwmabdWkPDUJ09gcBpuUarY0cuZ4YIq/7xrFJ+ta 9opJWOZRdXmsTvpBwar3cCizfVKjlB7yCUAQZFNNm5UefHuuhqvu9iOODQVa2w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665584330; a=rsa-sha256; cv=none; b=cm6dRIytj8WFsb8kwWSfS/Oe6QKcSfHfWr7PThqe6GVTt6o23lsMrsHrhfIuE2Wga8yN9k irYsLgqbtMtcJztwVMqLRk3FyC+0oNUi4g4bhiEeSYvmAcG3FO8Xl4LbLYDlgdIG98r1eo zdVuyPm0gOxJ8bUsIf9St9qsL6MaLLePdfOdaQIjbE94cjwPIaolEN99gyyVviKIEtZfpD h42ILnUyvFHaHt4bDa61p1wWksfdm4Y04Oq1XLFrmmYtakmQZBDuqHkm7FriHgVV/gvYbe O5wApp3IVHArpjq6q1Uli87E/G4Ev7mTCnuk0dNO1goKj/11bxwgRtj1BAEXBg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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-Spam-Score: -3.30 Authentication-Results: aspmx1.migadu.com; dkim=none; 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-Queue-Id: 84D60278D3 X-Spam-Score: -3.30 X-Migadu-Scanner: scn0.migadu.com X-TUID: +k77CCpHraWW Hi, In Org 9.5, SVG images started being exported by the HTML exporter as rather than . The patch causing that was https://list.orgmode.org/87k0pemj6d.fsf@gmail.com/T/ with two arguments: 1) do not have an alt attribute 2) will not render some SVG file correctly if it has no viewBox (I'm assuming that the issue shown in that message is a missing viewBox). The reason I've noticed this change is that it broke my web pages. On my pages, I use SVG to display many automata, and they all share a common stylesheet. That stylesheet is not inlined into the SVG, rather, it is a separate file included in the SVG files with so that the browser only need to download it once. Infortunately, does not allow external stylesheets to be processed, so my stylesheets are now ignored. Note that one can also build SVG images that include other SVG images, or SVG images that have animations that start when you hover on some elements. All those usages would break with . I've seen that very issue was discussed back in 2016 https://list.orgmode.org/871t2iq353.fsf@iki.fi/T/ where Christian Moe pointed out exactly this: > (2) You can also do other things with that you cannot with > , like manipulating the SVG with Javascript and styling it with > an external stylesheet (linked from the SVG, not the web page). So in the interest of allowing users to build documents where SVG files are not static, self-contained images, it seems to me that Org probably needs some way to specify whether SVG images should be exported as or (or maybe even inlined). Also regarding the alt attribute, maybe the code exporting Your browser does not support SVG could be taught to use alt text when such an alt= attribute is given. (I have no clue if that's "accessible" enough.) In the meantime, I'm advicing org-html--format-image as follows to get the original behavior in my project. (I also need to support different Org-mode versions, hence the fboundp check.) ;;; Org-mode 9.5 is now using to render SVG images. ;;; Unfortunately, this breaks SVG images that use external style ;;; sheets as are expected to be self-contained. ;;; ;;; Since we do use such external style-sheets and never had ;;; any issue with , we revert ;;; to the previous behavior. ;;; ;;; The following function is based on org-html--svg-image from ;;; Org-mode 9.4.5, with the addition of the SVG extension test. (defun spot-svg-output-as-object (source attributes info) "If source is an SVG file, return an \"object\" embedding svg file SOURCE with given ATTRIBUTES. INFO is a plist used as a communication channel. Otherwise return nil. The special attribute \"fallback\" can be used to specify a fallback image file to use if the object embedding is not supported. CSS class \"org-svg\" is assigned as the class of the object unless a different class is specified with an attribute." (when (string= "svg" (file-name-extension source)) (let ((fallback (plist-get attributes :fallback)) (attrs (org-html--make-attribute-string (org-combine-plists ;; Remove fallback attribute, which is not meant to ;; appear directly in the attributes string, and ;; provide a default class if none is set. '(:class "org-svg") attributes '(:fallback nil))))) (format "\n%s" source attrs (if fallback (org-html-close-tag "img" (format "src=\"%s\" %s" fallback attrs) info) "Sorry, your browser does not support SVG."))))) ;;; Hack org-html--format-image to call the above first. ;;; (The org-html--svg-image function was removed when the formater code ;;; switched to for SVG.) (unless (fboundp 'org-html--svg-image) (advice-add 'org-html--format-image :before-until 'spot-svg-output-as-object)) -- Alexandre