From: Kornel Benko Date: Wed, 20 Feb 2019 13:14:50 +0000 (+0100) Subject: FindAdv: Added handling for latex environments X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=829545e416205b55ae68e6818c9e65342086c287;p=features.git FindAdv: Added handling for latex environments 1.) Make sure the environment is mentioned in the string for search (Added the keyword \latexenvironment{...}) 2.) Handle it similar to \textcolor{} That way we can also search for 'conclusion*' or 'summary' etc in Additional.lyx. --- diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 9c98540d3a..20bef8dce0 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -951,7 +951,7 @@ static size_t identifyLeading(string const & s) // @TODO Support \item[text] // Kornel: Added textsl, textsf, textit, texttt and noun // + allow to search for colored text too - while (regex_replace(t, t, REGEX_BOS "\\\\(((footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage)\\{[a-z]+\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{", "") + while (regex_replace(t, t, REGEX_BOS "\\\\(((footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage|latexenvironment)\\{[a-z]+\\*?\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{", "") || regex_replace(t, t, REGEX_BOS "\\$", "") || regex_replace(t, t, REGEX_BOS "\\\\\\[ ", "") || regex_replace(t, t, REGEX_BOS " ?\\\\item\\{[a-z]+\\}", "") @@ -972,12 +972,12 @@ typedef map Features; static Features identifyFeatures(string const & s) { - static regex const feature("\\\\(([a-zA-Z]+(\\{([a-z]+)\\}|\\*)?))\\{"); + static regex const feature("\\\\(([a-zA-Z]+(\\{([a-z]+\\*?)\\}|\\*)?))\\{"); static regex const valid("^(" "(" "(footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|" "emph|noun|text(bf|md|sl|sf|it|tt)|" - "(textcolor|foreignlanguage|item|listitem)\\{[a-z]+\\})|" + "(textcolor|foreignlanguage|item|listitem|latexenvironment)\\{[a-z]+\\*?\\})|" "(u|uu)line|(s|x)out|uwave|" "(sub|extra)?title|author|subject|publishers|dedication|(upper|lower)titleback|lyx(right)?address)|" "((sub)?(((sub)?section)|paragraph)|part|chapter|lyxslide)\\*?)$"); @@ -1796,6 +1796,7 @@ void LatexInfo::buildKeys(bool isPatternString) // Split is done, if not at start of region makeKey("textcolor", KeyInfo(KeyInfo::isStandard, 2, ignoreFormats.getColor()), isPatternString); + makeKey("latexenvironment", KeyInfo(KeyInfo::isStandard, 2, false), isPatternString); // Split is done always. makeKey("foreignlanguage", KeyInfo(KeyInfo::isMain, 2, ignoreFormats.getLanguage()), isPatternString); diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 4e637ee805..8beb09623b 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -697,6 +697,11 @@ void parStartCommand(Paragraph const & par, otexstream & os, os << " "; } break; + case LATEX_ENVIRONMENT: + if (runparams.for_search) { + os << "\\latexenvironment{" << style.latexname() << "}{"; + } + break; case LATEX_BIB_ENVIRONMENT: // ignore this, the inset will write itself break;