[LyX/master] Amend 59509e2afa3f

Juergen Spitzmueller <[email protected]> Wed, 06 May 2026 10:19:42 +0000
Newsgroups gmane.editors.lyx.cvs
Message-ID <[email protected]>
commit 0db69518726354f0448dc5654ba841d54aa0769f
Author: Juergen Spitzmueller <[email protected]>
Date:   Wed May 6 12:19:22 2026 +0200

    Amend 59509e2afa3f
    
    Consider custom color as well
---
 src/tex2lyx/Preamble.cpp | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 2a4a9e1a79..61dac99ac9 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -3623,22 +3623,33 @@ void Preamble::parse(Parser & p, string const & forceclass,
 		if (t.cs() == "colorlet") {
 			string const color1 = p.getArg('{', '}');
 			string const color2 = p.getArg('{', '}');
-			if (color1 == "document_fontcolor")
+			bool is_known_source_col = false;
+			if (color1 == "document_fontcolor") {
 				h_fontcolor = getLyXColor(color2, true);
-			else if (color1 == "note_fontcolor")
+				is_known_source_col = true;
+			} else if (color1 == "note_fontcolor") {
 				h_notefontcolor = getLyXColor(color2, true);
-			else if (color1 == "page_backgroundcolor")
+				is_known_source_col = true;
+			} else if (color1 == "page_backgroundcolor") {
 				h_backgroundcolor = getLyXColor(color2, true);
-			else if (color1 == "shadecolor")
+				is_known_source_col = true;
+			} else if (color1 == "shadecolor") {
 				h_boxbgcolor = getLyXColor(color2, true);
-			else if (theLaTeXColors().isLaTeXColor(color2)) {
+				is_known_source_col = true;
+			} else if (h_custom_colors.find(color2) != h_custom_colors.end()) {
+				// a known custom color
+				h_custom_colors[color1] = h_custom_colors[color2];
+			} else if (theLaTeXColors().isLaTeXColor(color2)) {
+				// check if the source is a known defined color
 				for (auto const & cc : theLaTeXColors().getLaTeXColors()) {
 					if (cc.first == color2) {
 						h_custom_colors[color1] = ltrim(cc.second.hexname(), "#");
+						is_known_source_col = true;
 						break;
 					}
 				}
-			} else {
+			}
+			if (!is_known_source_col) {
 				h_preamble << "\\colorlet{" << color1
 				           << "}{" << color2 << '}';
 			}
-- 
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs