commit 6d30ded2aac09433d076241ca93ca8f5a6e9ec75
Author: Juergen Spitzmueller <sp...@lyx.org>
Date:   Thu Apr 3 17:51:33 2025 +0200

    Warn on invalid label in prettyref context
---
 src/insets/InsetRef.cpp | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp
index eedc9725f9..901f9c22ca 100644
--- a/src/insets/InsetRef.cpp
+++ b/src/insets/InsetRef.cpp
@@ -29,6 +29,8 @@
 #include "texstream.h"
 #include "TocBackend.h"
 
+#include "frontends/alert.h"
+
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
@@ -379,8 +381,16 @@ void InsetRef::latex(otexstream & os, OutputParams const & 
rp) const
                                // refstyle bug: labels with blanks need to be 
grouped
                                // otherwise the blanks will be gobbled
                                os << "{" << *it << "}";
-                       else
+                       else {
+                               if (buffer().masterParams().xref_package == 
"prettyref" && !contains(*it, ':'))
+                                       // warn on invalid label
+                                       frontend::Alert::warning(_("Invalid 
label!"),
+                                                                bformat(_("The 
label `%1$s' does not have a prefix (e.g., `sec:'), "
+                                                                          
"which is needed for formatted references with prettyref.\n"
+                                                                          "You 
will most likely run into a LaTeX error."),
+                                                                        *it), 
true);
                                os << *it;
+                       }
                        first = false;
                }
                os << "}";
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to