]> git.lyx.org Git - lyx.git/commitdiff
FindAdv: Amend 58f70b9d
authorKornel Benko <kornel@lyx.org>
Wed, 6 Apr 2022 17:00:20 +0000 (19:00 +0200)
committerKornel Benko <kornel@lyx.org>
Wed, 6 Apr 2022 17:00:20 +0000 (19:00 +0200)
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
src/lyxfind.cpp

index 3dfed9e419f132b4c941254821749167734b591e..67ad7672dd0132abfc504f093a976f42d8164983 100644 (file)
@@ -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;
+       }
 }
 
 
index 64da365ebbac2cf86f2950fff18dc80e08665e1e..0f02a3991615e17ae29f67ff53875847a5c0f163 100644 (file)
@@ -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;
 }