]> git.lyx.org Git - features.git/commitdiff
FindAdv: Added handling for latex environments
authorKornel Benko <kornel@lyx.org>
Wed, 20 Feb 2019 13:14:50 +0000 (14:14 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 12:39:58 +0000 (14:39 +0200)
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.

src/lyxfind.cpp
src/output_latex.cpp

index 9c98540d3af7bb3018d650738d5c7f7382c2b966..20bef8dce05e263f6015e29c4ac224448ec76a82 100644 (file)
@@ -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<string, bool> 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);
index 4e637ee8056bad4385350191f39c4f3677c143a9..8beb09623b562cb336a335dfa39362897c787b5e 100644 (file)
@@ -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;