From: Tommaso Cucinotta Date: Sat, 20 Nov 2010 15:57:54 +0000 (+0000) Subject: Finds formatted matches in the middle of paragraphs, when no regular expressions... X-Git-Tag: 2.0.0~1757 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=630953e6133383e7a431fc4878fb96321f37dded;p=features.git Finds formatted matches in the middle of paragraphs, when no regular expressions are involved (fixes #6891). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36411 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 937838d51b..6b9d4d7e5f 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -772,7 +772,12 @@ int MatchStringAdv::findAux(DocIterator const & cur, int len, bool at_begin) con if (str.substr(0, par_as_string.size()) == par_as_string) return par_as_string.size(); } else { - size_t pos = str.find(par_as_string); + string t = par_as_string; + while (regex_replace(t, t, "\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph|part)\\{", "") + || regex_replace(t, t, "^\\$", "") + || regex_replace(t, t, "^\\\\\\[ ", "")) + LYXERR(Debug::FIND, " after removing leading $, \[ , \\emph{, \\textbf{, etc.: " << t); + size_t pos = str.find(t); if (pos != string::npos) return par_as_string.size(); } @@ -844,7 +849,7 @@ string MatchStringAdv::normalize(docstring const & s) const t.replace(pos, 1, " "); // Remove stale empty \emph{}, \textbf{} and similar blocks from latexify LYXERR(Debug::FIND, "Removing stale empty \\emph{}, \\textbf{}, \\*section{} macros from: " << t); - while (regex_replace(t, t, "\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph)(\\{\\})+", "")) + while (regex_replace(t, t, "\\\\(emph|textbf|subsubsection|subsection|section|subparagraph|paragraph|part)(\\{\\})+", "")) LYXERR(Debug::FIND, " further removing stale empty \\emph{}, \\textbf{} macros from: " << t); return t; }