commit 40dd37089d39010105ae7163c07733ed515c54be
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Sun Dec 15 09:49:36 2024 +0100

    Fix erroneous whitespace before and after math preview (#13127)
---
 lib/scripts/legacy_lyxpreview2ppm.py | 9 +++++++--
 src/mathed/InsetMathHull.cpp         | 3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/scripts/legacy_lyxpreview2ppm.py 
b/lib/scripts/legacy_lyxpreview2ppm.py
index 77636e340e..71ec171a87 100644
--- a/lib/scripts/legacy_lyxpreview2ppm.py
+++ b/lib/scripts/legacy_lyxpreview2ppm.py
@@ -258,8 +258,13 @@ def legacy_latex_file(latex_file, fg_color, bg_color):
         tmp.write(b"""
 \\usepackage[%s,tightpage]{preview}
 \\makeatletter
-\\g@addto@macro\\preview{\\leavevmode\\begingroup\\color{lyxbg}\\special{background
 \\current@color}\\special{ps::clippath fill}\\color{lyxfg}}
-\\g@addto@macro\\endpreview{\\endgroup}
+\\ifdefined\\AddToHook
+  
\\AddToHook{env/preview/before}{\\leavevmode\\begingroup\\color{lyxbg}\\special{background
 \\current@color}\\special{ps::clippath fill}\\color{lyxfg}}
+  \\AddToHook{env/preview/after}{\\endgroup}
+\\else
+  
\\g@addto@macro\\preview{\\leavevmode\\begingroup\\color{lyxbg}\\special{background
 \\current@color}\\special{ps::clippath fill}\\color{lyxfg}}
+  \\g@addto@macro\\endpreview{\\endgroup}
+\\fi
 \\let\\pr@set@pagerightoffset\\@empty
 \\ifx\\pagerightoffset\\@undefined\\else
   \\def\\pr@set@pagerightoffset{\\ifnum\\pagedirection=1
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index efefb04fa0..4cc695334e 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -883,7 +883,8 @@ void InsetMathHull::preparePreview(DocIterator const & pos,
        if (lsize != "normalsize" && !prefixIs(lsize, "error"))
                setfont += from_ascii("\\" + lsize + '\n');
 
-       docstring const snippet = macro_preamble + setfont + latexString(*this) 
+ endfont;
+       docstring const snippet = macro_preamble + setfont
+               + trim(latexString(*this), "\n") + endfont;
        LYXERR(Debug::MACROS, "Preview snippet: " << snippet);
        preview_->addPreview(snippet, *buffer, forexport);
 }
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to