Hi Stefan,

Stefan Monnier <[email protected]> writes:

>     [...]
> and Org seems to generate the following from it:
>     [...]

Sorry for the trouble. The cause is on my side: `#+BEGIN_HTML' has not
been an export block since Org 8.0. Current Org reads it as a special
block named "HTML", so its contents are parsed as Org text, which gives
the escaped tags and the bare image URLs turned into <img> that you saw.

> Github happily displays this Org's content as a table of screenshots
> (https://github.com/szymonwilczek/au-themes/blob/main/README.org), but
> my Org/HTML-fu is not strong enough to understand why.

GitHub renders Org with org-ruby, which still knows only the old syntax.
It treats `#+BEGIN_HTML' as raw HTML, but it would hide a
`#+BEGIN_EXPORT html' block, so the modern form would remove the gallery
from GitHub. The single-line `#+HTML:' keyword works in both, so I have
switched the README to it, and also gave the headings the internal links
point to a CUSTOM_ID. It is now in the repo.

> Can someone shed some light on this (so I can improve `elpa-admin.el` to
> fix the false positives above)?

The messages come from the regexp in `elpaa--doc-html-adjust-auxfiles',
which matched ` src="<img src="' inside the escaped text.

I've attached the patch that requires the attribute to be inside a real
tag (the FIXME next to that loop). With my old README it goes from 18
matches to none, and it still finds relative `src' attributes, including
in tags over several lines. It also stops the old regexp from rewriting
escaped text such as `&lt;img src="foo.png"' when a file of that name
exists. Hope this helps.

Thanks,
Szymon

>From daaa56afef6daa9312db330708cf160a33695f66 Mon Sep 17 00:00:00 2001
From: Szymon Wilczek <[email protected]>
Date: Thu, 19 Nov 2026 18:10:00 +0100
Subject: [PATCH] elpa-admin.el: Only rewrite `src' attributes found inside
 tags

* elpa-admin.el (elpaa--doc-html-adjust-auxfiles): Require the `src'
attribute to be inside a tag, and the file name not to contain `<' or
`>'.  This skips text that only looks like an attribute, such as
escaped HTML in a paragraph.
---
 elpa-admin.el | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/elpa-admin.el b/elpa-admin.el
index 363f7cd..ea9edc3 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -3105,7 +3105,7 @@ directory; one of archive, archive-devel."
   ;; (let* ((auxfiles (elpaa--spec-get pkg-spec :doc-files)))
   ;;  (when auxfiles
   (let* ((docdir (if (stringp docfile) (file-name-directory docfile)))
-         (regexp " \\(?:src\\)=\"\\([^#/.\"][^:\"#]+\\)\""))
+         (regexp "<[[:alpha:]][^<>]*[ \t\n]src=\"\\([^#/.\"<>][^:\"#<>]*\\)\""))
     (with-current-buffer (if (stringp html-file)
                              (find-file-noselect html-file)
                            html-file)
@@ -3115,7 +3115,6 @@ directory; one of archive, archive-devel."
         (elpaa--message "default-directory=%S" default-directory)
         (goto-char (point-min))
         (let ((case-fold-search t))
-          ;; FIXME: Skip false positives found outside of tags!
           (while (re-search-forward regexp nil t)
             (message "found match for: %S" (match-string 1))
             (let* ((file (match-string 1))
-- 
2.56.1

Reply via email to