mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
Findadv: Handle \lettrine{} in initials.module
The problem here is, that selecting any subset of a \lettrine{} line always creates an initials header. That makes it impossible to our search engine to find strings, because the regex does not contain that info. So we have to discard the leading \lettrine part completely. We place now a marker (\endarguments) to determine that removable part.
This commit is contained in:
parent
051b6ce68a
commit
50550a215f
@ -1037,7 +1037,10 @@ class KeyInfo {
|
|||||||
/* item */
|
/* item */
|
||||||
isList,
|
isList,
|
||||||
/* tex, latex, ... like isChar */
|
/* tex, latex, ... like isChar */
|
||||||
isIgnored
|
isIgnored,
|
||||||
|
/* like \lettrine[lines=5]{}{} */
|
||||||
|
cleanToStart,
|
||||||
|
endArguments
|
||||||
};
|
};
|
||||||
KeyInfo()
|
KeyInfo()
|
||||||
: keytype(invalid),
|
: keytype(invalid),
|
||||||
@ -1755,7 +1758,8 @@ void LatexInfo::buildKeys(bool isPatternString)
|
|||||||
makeKey("par|uldepth|ULdepth|protect|nobreakdash", KeyInfo(KeyInfo::isStandard, 0, true), isPatternString);
|
makeKey("par|uldepth|ULdepth|protect|nobreakdash", KeyInfo(KeyInfo::isStandard, 0, true), isPatternString);
|
||||||
// Remove RTL/LTR marker
|
// Remove RTL/LTR marker
|
||||||
makeKey("l|r|textlr|textfr|textar|beginl|endl", KeyInfo(KeyInfo::isStandard, 0, true), isPatternString);
|
makeKey("l|r|textlr|textfr|textar|beginl|endl", KeyInfo(KeyInfo::isStandard, 0, true), isPatternString);
|
||||||
|
makeKey("lettrine", KeyInfo(KeyInfo::cleanToStart, 0, true), isPatternString);
|
||||||
|
makeKey("endarguments", KeyInfo(KeyInfo::endArguments, 0, true), isPatternString);
|
||||||
if (isPatternString) {
|
if (isPatternString) {
|
||||||
// Allow the first searched string to rebuild the keys too
|
// Allow the first searched string to rebuild the keys too
|
||||||
keysBuilt = false;
|
keysBuilt = false;
|
||||||
@ -1891,6 +1895,35 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
|
|||||||
int nextKeyIdx = 0;
|
int nextKeyIdx = 0;
|
||||||
switch (actual.keytype)
|
switch (actual.keytype)
|
||||||
{
|
{
|
||||||
|
case KeyInfo::cleanToStart: {
|
||||||
|
actual._dataEnd = actual._dataStart;
|
||||||
|
if (interval.par[actual._dataStart] == '[') {
|
||||||
|
// Discard optional params
|
||||||
|
actual._dataStart = interval.findclosing(actual._dataStart+1, interval.par.length(), '[', ']') + 1;
|
||||||
|
}
|
||||||
|
actual._dataEnd = actual._dataStart;
|
||||||
|
nextKeyIdx = getNextKey();
|
||||||
|
// Search for end of arguments
|
||||||
|
int tmpIdx = nextKeyIdx;
|
||||||
|
while (tmpIdx > 0) {
|
||||||
|
KeyInfo &nextk = entries[tmpIdx];
|
||||||
|
if (nextk.keytype == KeyInfo::endArguments) {
|
||||||
|
actual._dataEnd = nextk._dataEnd;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nextk.disabled = true;
|
||||||
|
tmpIdx++;
|
||||||
|
if (tmpIdx >= int(entries.size()))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (interval.par[actual._dataEnd] == ' ')
|
||||||
|
actual._dataEnd++;
|
||||||
|
interval.addIntervall(0, actual._dataEnd+1);
|
||||||
|
interval.actualdeptindex = 0;
|
||||||
|
interval.depts[0] = actual._dataEnd+1;
|
||||||
|
interval.closes[0] = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case KeyInfo::noContent: { /* char like "\hspace{2cm}" */
|
case KeyInfo::noContent: { /* char like "\hspace{2cm}" */
|
||||||
interval.addIntervall(actual._dataStart, actual._dataEnd);
|
interval.addIntervall(actual._dataStart, actual._dataEnd);
|
||||||
}
|
}
|
||||||
@ -1929,6 +1962,11 @@ int LatexInfo::dispatch(ostringstream &os, int previousStart, KeyInfo &actual)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case KeyInfo::endArguments:
|
||||||
|
removeHead(actual);
|
||||||
|
processRegion(actual._dataStart, actual._dataStart+1);
|
||||||
|
nextKeyIdx = getNextKey();
|
||||||
|
break;
|
||||||
case KeyInfo::noMain:
|
case KeyInfo::noMain:
|
||||||
// fall through
|
// fall through
|
||||||
case KeyInfo::isStandard: {
|
case KeyInfo::isStandard: {
|
||||||
|
@ -530,6 +530,10 @@ void getArgInsets(otexstream & os, OutputParams const & runparams, Layout::LaTeX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (runparams.for_search) {
|
||||||
|
// Mark end of arguments for findadv() only
|
||||||
|
os << "\\endarguments{}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user