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 ms9.migadu.com with LMTPS id IG4LIKktf2RqfwEASxT56A (envelope-from ) for ; Tue, 06 Jun 2023 14:59:21 +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 iGzDH6ktf2QX4gAA9RJhRA (envelope-from ) for ; Tue, 06 Jun 2023 14:59:21 +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 90FDC3C4F3 for ; Tue, 6 Jun 2023 14:59:19 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6WGZ-0007iM-Lo; Tue, 06 Jun 2023 08:58:28 -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 1q6WGV-0007hy-BH for emacs-orgmode@gnu.org; Tue, 06 Jun 2023 08:58:23 -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 1q6WGS-0006If-4l for emacs-orgmode@gnu.org; Tue, 06 Jun 2023 08:58:22 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 43146240104 for ; Tue, 6 Jun 2023 14:58:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1686056296; bh=28adj6cKl4XNQJjSMQX/1BvOsV1ARvTzXTIOGKME4wU=; h=MIME-Version:Content-Transfer-Encoding:Date:From:To:Cc:Subject: Message-ID:From; b=csLLDxXLc6+P4kJfnVs0hyIUxmGS8m+AGIZOptUpbwBwHhuuofRpr3BIppIQMFQDr /7OLhGWpUdaJaM+32Zpyq0eQILdItUChw9OLolRSwiBxfGZDumlU1kxhn/CUw4BGcz EOkGwT2+ilSwaZGBQM0e0Zh9C5utPGllStgA0x6t/UXi8FXX4LvT1OT3omyRBz9ppv cgNnyb9D3SWMx5TLPqX26vL8nqLQrCHy/phHrPFtQA4F1aiYoqcEUiJNh1oulfScKC tkJ58f0YivroJcQH0fX0GnKOE7p/c3xFgD3OFAMD7k78ZiUgNJuOqCY4TsnOOe59vg fl5tgd5vBApfg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Qb9WW4SVKz6twb; Tue, 6 Jun 2023 14:58:15 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 06 Jun 2023 12:58:15 +0000 From: gerard.vermeulen@posteo.net To: Ihor Radchenko Cc: Timothy , Emacs orgmode , Christian Moe Subject: Re: [PATCH] ox-html.el: add option to embed SVG for CSS support in SVG In-Reply-To: <871qip3u90.fsf@localhost> References: <871qip3u90.fsf@localhost> Message-ID: Received-SPF: pass client-ip=185.67.36.66; envelope-from=gerard.vermeulen@posteo.net; helo=mout02.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-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1686056360; 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=LxU6uI+rLFmXefRdXN4cU9pnDuSRGpy5Vg3fYU/SYiM=; b=BgE296Det6fVkGcttEw+q0dELY3dCOgCcLn4tqVVwfDhq7NeZIuZgc5t+/SnmMDusZwkv5 I126zZNaySnyG5B3rb9d9uyfyPmWdJyQKXFIGid6G0Gqfwpbcme/u58OmWQSAO6WL/fhH7 yrjwwNJlDPLxhNPJy4jD98f0JN7mJHOBnnpFmO3BWZUOzN7zU1qqJo0EJTDdlbPI8l5KHq cIXW2H3Qj8BzFQ+ME64g+UydzgoIDbIdYzfwBxi12f2djR9UDc+lR07JFT0axaAJ9wTACI kl5zemIqOG4VtqC49rjfvHTTwrux3J6GwAEn0cGS4bcWhi0PMnc95SGFR3X7oA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=csLLDxXL; 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-Seal: i=1; s=key1; d=yhetil.org; t=1686056360; a=rsa-sha256; cv=none; b=GKJgaRNEKsC2gvhBJWNnDKsrCbGLk1FqbBECK4o0e66ejWTpwrhsxJ7fIS2hJgFlM4O3gl 54JbNPijER27216LNtIzQEODUR2pTVA7vvfSw0chVvn/VbMPC9xQVlNHyWBaMMXyqQVNRX 1dNuRH72XXIWflW3hm8CN8e2GE+vnhyYMF1C8SkJn3Jrjk/VssaYtYSly+bzFlu5+jbuzY 7uXiHo0dlRgDRtcH7K7k+LhNaVUDeQTendIB0YB82WctSWim1STFVxMRWkl6qOIPFwyMSW vTNgTEAuAfPrxqz4Bv6ZQ2Y2LTOhUz7/Ja57pJKb7e0a1w9YBFmLdgId9AlT1Q== X-Migadu-Scanner: scn1.migadu.com X-Migadu-Spam-Score: -6.65 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=csLLDxXL; 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: 90FDC3C4F3 X-Spam-Score: -6.65 X-TUID: o0RH7Fik4QRb On 06.06.2023 09:49, Ihor Radchenko wrote: > 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? > No, it means that custom CSS inside a linked SVG image is shielded from the page that has the link to the SVG image. To me it looks a natural defense against linking to different SVG images linking to conflicting custom CSS. If the HTML page linking to those images should manage the conflicting custom CSS, the creator of the page is responsible for resolving the conflicts. > >> 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"? I do not think that #+ATTR_HTML allows to embed (= copy) the contents of an SVG file directly into the HTML page. As far as I understand, it adds only attributes to HTML elements. The "split" is because of similarity with :select_tags and :exclude_tags in ox. It allows several files to be included in or excluded from embedding. I agree that an attribute like #+EMBED_SVG is less awkward. > >> + (:with-html-svg-embedding nil "html-embed-svg" >> org-html-embed-svg) > > We have :html-inline-images. Maybe better :html-embed-svg ? I agree (the patch started as an derived backend with ox-beamer as an example where those kind of variables are prefixed with :with; this is a left-over). > >> +(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". My fault. > > 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'. I think that the terminology "inline-image" in ox-html is confusing. In ox-html the result of the "inline-image" code is an HTML tag like It does not mean that image data is copied inline as with embedding. > >> +(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? Yes, I pretend that my code is an improvement: 1. The with-syntax-table is superfluous. 2. The error message gives a reason and the filename causing it.