org-latex-preview: Get face from char before latex

* lisp/org-latex-preview.el (org-create-latex-preview): Instead of
getting the face using `face-at-point' use `get-text-property' on the
position one before the start of the LaTeX fragment.  This ensures that
the face is that of the parent element rather than the LaTeX fragment.
This commit is contained in:
TEC 2022-12-27 00:14:44 +08:00
parent dd20868ff3
commit a1c0b82930
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 3 additions and 3 deletions

View File

@ -515,9 +515,9 @@ Some of the options can be changed using the variable
(skip-chars-backward " \r\t\n")
(point)))
(value (org-element-property :value element))
(face (save-excursion
(goto-char beg)
(face-at-point)))
(face (or (and (> beg 1)
(get-text-property (1- beg) 'face))
'default))
(fg (pcase (plist-get org-format-latex-options :foreground)
('auto (face-attribute face :foreground nil 'default))
('default (face-attribute 'default :foreground nil))