[LyX/master] FindAdv: Amend 58f70b9d
Kornel Benko
kornel at lyx.org
Wed Apr 6 16:31:39 UTC 2022
commit aa66663364c44047bd97c919a651b8adcaf7617a
Author: Kornel Benko <kornel at lyx.org>
Date: Wed Apr 6 19:00:20 2022 +0200
FindAdv: Amend 58f70b9d
Consider plain-quotes, inner-quotes
1 independent if in regex or text
2 independent of quote style
3 independent of using dynamic marks
---
src/insets/InsetQuotes.cpp | 17 +++++++++++++----
src/lyxfind.cpp | 9 ++++++++-
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp
index 3dfed9e..67ad767 100644
--- a/src/insets/InsetQuotes.cpp
+++ b/src/insets/InsetQuotes.cpp
@@ -942,11 +942,20 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
int InsetQuotes::plaintext(odocstringstream & os,
- OutputParams const &, size_t) const
+ OutputParams const & op, size_t) const
{
- docstring const str = displayString();
- os << str;
- return str.size();
+ if (op.for_searchAdv == OutputParams::NoSearch) {
+ docstring const str = displayString();
+ os << str;
+ return str.size();
+ }
+ else {
+ if (level_ == QuoteLevel::Primary)
+ os << from_ascii("\"");
+ else
+ os << from_ascii("'");
+ return 1;
+ }
}
diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp
index 64da365..0f02a39 100644
--- a/src/lyxfind.cpp
+++ b/src/lyxfind.cpp
@@ -909,9 +909,16 @@ string correctRegex(string t, bool withformat)
lastpos = sub.position(2) + sub.length(2);
}
if (lastpos == 0)
- return t;
+ s = t;
else if (lastpos < t.length())
s += t.substr(lastpos, t.length() - lastpos);
+ // Handle quotes in regex
+ // substitute all '„', '“' with '"'
+ // and all '‚', '‘' with "\'"
+ static std::regex plainquotes { R"(„|“)" };
+ static std::regex innerquotes { R"(‚|‘)" };
+ t = std::regex_replace(s, plainquotes, R"(")");
+ s = std::regex_replace(t, innerquotes, R"(')");
//LYXERR0("correctRegex output '" << s << "'");
return s;
}
More information about the lyx-cvs
mailing list