emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@posteo.net>
To: gerard.vermeulen@posteo.net, Timothy <orgmode@tec.tecosaur.net>
Cc: Emacs orgmode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ox-html.el: add option to embed SVG for CSS support in SVG
Date: Tue, 06 Jun 2023 07:49:47 +0000	[thread overview]
Message-ID: <871qip3u90.fsf@localhost> (raw)
In-Reply-To: <c1eef10be815748d2103cb81bce08708@posteo.net>

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 <svg 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?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


  reply	other threads:[~2023-06-06  7:46 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 13:23 [PATCH] ox-html.el: add option to embed SVG for CSS support in SVG gerard.vermeulen
2023-06-06  7:49 ` Ihor Radchenko [this message]
2023-06-06  9:57   ` Christian Moe
2023-06-06 13:37     ` gerard.vermeulen
2023-06-06 18:54       ` Christian Moe
2023-06-07  8:43         ` Ihor Radchenko
2023-06-07  8:41     ` Ihor Radchenko
2023-06-07 14:30       ` Christian Moe
2023-06-07 17:57         ` Ihor Radchenko
2023-06-15 13:09           ` gerard.vermeulen
2023-06-15 14:55             ` Max Nikulin
2023-06-15 20:42               ` Ihor Radchenko
2023-06-15 20:51             ` Ihor Radchenko
2023-06-16 18:39               ` gerard.vermeulen
2023-06-17 12:38                 ` Ihor Radchenko
2023-06-17 14:45                   ` gerard.vermeulen
2023-06-21 15:52               ` Max Nikulin
2023-06-21 16:02                 ` Ihor Radchenko
2023-06-21 16:27                   ` Max Nikulin
2023-06-21 16:38                     ` Ihor Radchenko
2023-06-22 16:25                       ` Max Nikulin
2023-06-23 11:02                         ` Ihor Radchenko
2023-06-06 12:58   ` gerard.vermeulen
2023-06-07  9:07     ` Ihor Radchenko
2023-06-06 14:14 ` Max Nikulin
2023-06-06 16:08   ` gerard.vermeulen
2023-06-07  9:10     ` Ihor Radchenko
2023-06-09 15:27     ` Max Nikulin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871qip3u90.fsf@localhost \
    --to=yantar92@posteo.net \
    --cc=emacs-orgmode@gnu.org \
    --cc=gerard.vermeulen@posteo.net \
    --cc=orgmode@tec.tecosaur.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).