commit fc1853ed9e5466091e623349fe0b2b1aaa39a78c
Author: Juergen Spitzmueller <[email protected]>
Date: Tue Aug 12 12:53:57 2025 +0200
Improve on a45cf357af98
The parentheses should be part of the l7n string
---
lib/layouts/scrbook.layout | 2 +-
lib/layouts/stdcounters.inc | 2 +-
src/insets/InsetFlex.cpp | 2 +-
src/insets/InsetLabel.cpp | 28 ++++++++++++++--------------
src/mathed/InsetMathHull.cpp | 19 +++++++++----------
5 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/lib/layouts/scrbook.layout b/lib/layouts/scrbook.layout
index e891b577b9..61429061b0 100644
--- a/lib/layouts/scrbook.layout
+++ b/lib/layouts/scrbook.layout
@@ -29,7 +29,7 @@ Counter equation
GuiName Equation
Within chapter
LabelString "\thechapter.\arabic{equation}"
- PrettyFormat "Equation|Equations \thechapter.\arabic{equation}"
+ PrettyFormat "Equation|Equations (\thechapter.\arabic{equation})"
End
diff --git a/lib/layouts/stdcounters.inc b/lib/layouts/stdcounters.inc
index e8f68c1d2c..cb818eb953 100644
--- a/lib/layouts/stdcounters.inc
+++ b/lib/layouts/stdcounters.inc
@@ -84,7 +84,7 @@ End
Counter equation
GuiName Equation
- PrettyFormat "Equation|Equations ##"
+ PrettyFormat "Equation|Equations (##)"
End
Counter footnote
diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp
index a77591414b..2053bb80c4 100644
--- a/src/insets/InsetFlex.cpp
+++ b/src/insets/InsetFlex.cpp
@@ -174,7 +174,7 @@ void InsetFlex::updateBuffer(ParIterator const & it,
UpdateType utype, bool cons
cnts.newCounter(equation, parentequation,
eqlabel + from_ascii("\\alph{equation}"),
eqlabel + from_ascii("\\alph{equation}"),
- from_ascii("Equation|Equations ##"),
+ from_ascii("Equation|Equations (##)"),
cnts.guiName(parentequation));
InsetCollapsible::updateBuffer(it, utype, deleted);
// reset equation counter as it was.
diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp
index d2057779dc..1d078a23cf 100644
--- a/src/insets/InsetLabel.cpp
+++ b/src/insets/InsetLabel.cpp
@@ -187,25 +187,25 @@ void InsetLabel::setFormattedCounter(docstring const &
fc, bool const lc, bool c
namespace {
-docstring stripSubrefs(docstring const & in, bool const parens){
+docstring stripSubrefs(docstring const & in){
docstring res;
bool have_digit = false;
size_t const len = in.length();
for (size_t i = 0; i < len; ++i) {
// subref can be an alphabetic letter or '?'
// as soon as we encounter this, break
- if (have_digit && (isLetterChar(in[i]) || in[i] == '?'))
- return parens ? res + ")" : res;
+ char_type const c = in[i];
+ if (have_digit && (('a' <= c && c <= 'z') || c == '?'))
+ continue;
else {
- if (isNumberChar(in[i]) && !have_digit) {
- if (parens)
- res += "(";
+ if (isNumberChar(c) && !have_digit)
have_digit = true;
- }
- res += in[i];
+ else if (have_digit)
+ have_digit = false;
+ res += c;
}
}
- return parens ? res + ")" : res;
+ return res;
}
}
@@ -302,11 +302,11 @@ void InsetLabel::updateBuffer(ParIterator const & it,
UpdateType, bool const /*d
if (equation) {
// FIXME: special code just for the
subequations module (#13199)
// replace with a genuine solution
long-term!
- counter_value_ = stripSubrefs(counter_value_,
false);
- formatted_counter_ =
stripSubrefs(formatted_counter_, true);
- formatted_counter_pl_ =
stripSubrefs(formatted_counter_pl_, true);
- formatted_counter_lc_ =
stripSubrefs(formatted_counter_lc_, true);
- formatted_counter_lc_pl_ =
stripSubrefs(formatted_counter_lc_pl_, true);
+ counter_value_ = stripSubrefs(counter_value_);
+ formatted_counter_ =
stripSubrefs(formatted_counter_);
+ formatted_counter_pl_ =
stripSubrefs(formatted_counter_pl_);
+ formatted_counter_lc_ =
stripSubrefs(formatted_counter_lc_);
+ formatted_counter_lc_pl_ =
stripSubrefs(formatted_counter_lc_pl_);
}
} else {
// For equations, the counter value and pretty counter
diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp
index c8b5d19bc4..98206b3063 100644
--- a/src/mathed/InsetMathHull.cpp
+++ b/src/mathed/InsetMathHull.cpp
@@ -285,20 +285,19 @@ void InsetMathHull::updateBuffer(ParIterator const & it,
UpdateType utype, bool
for (row_type row = 0; row != nrows(); ++row) {
if (numbered(row) && labels_[row]) {
labels_[row]->setCounterValue(numbers_[row]);
- docstring const embraced_num = "(" + numbers_[row] +
")";
- labels_[row]->setPrettyCounter(embraced_num);
+ labels_[row]->setPrettyCounter("(" + numbers_[row] +
")");
// lowercase singular
- docstring pf = translateIfPossible(from_ascii("equation
##"), lang);
- labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), embraced_num), true, false);
+ docstring pf = translateIfPossible(from_ascii("equation
(##)"), lang);
+ labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), numbers_[row]), true, false);
// lowercase plural
- pf = translateIfPossible(from_ascii("equations ##"),
lang);
- labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), embraced_num), true, true);
+ pf = translateIfPossible(from_ascii("equations (##)"),
lang);
+ labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), numbers_[row]), true, true);
// uppercase singular
- pf = translateIfPossible(from_ascii("Equation ##"),
lang);
- labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), embraced_num), false, false);
+ pf = translateIfPossible(from_ascii("Equation (##)"),
lang);
+ labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), numbers_[row]), false, false);
// uppercase plural
- pf = translateIfPossible(from_ascii("Equations ##"),
lang);
- labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), embraced_num), false, true);
+ pf = translateIfPossible(from_ascii("Equations (##)"),
lang);
+ labels_[row]->setFormattedCounter(subst(pf,
from_ascii("##"), numbers_[row]), false, true);
}
}
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs