Rudolf Adamkovič <[email protected]> writes:

> I found that the single space character after certain[1] entities and
> inline LaTeX fragment is fontified as `org-block'.  This is invisible
> with the default Emacs non-theme, but it is visually confusing when a
> theme[2] is loaded that gives `org-block' non-transparent background.

Could you try the attached patch?
>From 0b29108f13e58609c6f612b188de24066dc8aaf4 Mon Sep 17 00:00:00 2001
Message-ID: <0b29108f13e58609c6f612b188de24066dc8aaf4.1760798244.git.yanta...@posteo.net>
From: Ihor Radchenko <[email protected]>
Date: Sat, 18 Oct 2025 16:33:55 +0200
Subject: [PATCH] org-do-latex-and-related: Do not fontify trailing whitespace
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/org.el (org-do-latex-and-related): Avoid fontifying trailing
whitespace after latex fragments and entities.

Reported-by: Rudolf Adamkovič <[email protected]>
Link: https://orgmode.org/list/[email protected]
---
 lisp/org.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 95fd46b4a..17ec51fa4 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5912,7 +5912,10 @@ (defun org-do-latex-and-related (limit)
 			       1
 			     0))
 		   (start (+ offset (match-beginning 0)))
-		   (end (match-end 0)))
+		   (end (save-excursion
+                          (goto-char (match-end 0))
+                          ;; Do not fontify trailing whitespace.
+                          (skip-chars-backward " \t") (point))))
 	      (if (memq 'native org-highlight-latex-and-related)
 		  (org-src-font-lock-fontify-block "latex" start end)
 		(font-lock-prepend-text-property start end
-- 
2.50.1


-- 
Ihor Radchenko // yantar92,
Org mode maintainer,
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 via email to