Allow to pass several styles for style-specific cite commands

This commit is contained in:
Juergen Spitzmueller 2024-07-11 10:09:26 +02:00
parent 04d8616c0a
commit f7cc716861
7 changed files with 34 additions and 11 deletions

View File

@ -24612,7 +24612,7 @@ LyXName|alias$*<!_stardesc!_stardesctooltip>[][]=latexcmd
\begin_layout Itemize \begin_layout Itemize
\change_inserted -712698321 1720623254 \change_inserted -712698321 1720682930
\begin_inset Flex Code \begin_inset Flex Code
status collapsed status collapsed
@ -24627,8 +24627,7 @@ style
\end_inset \end_inset
: :
If this is given, a (comma-separated) list of biblatex citation styles to which this command is specific.
the command is specific to this (biblatex) citation style.
E. E.
\begin_inset space \thinspace{} \begin_inset space \thinspace{}
\end_inset \end_inset

View File

@ -23470,8 +23470,8 @@ style
\end_inset \end_inset
: :
Wenn dies angegeben wird, eine (kommaseparierter) Liste von (Biblatex-)Zitierstilen,
wird der Befehl als spezifisch für einen (Biblatex-)Zitierstil markiert. für die der Befehl spezifisch ist.
Mit Mit
\begin_inset Flex Code \begin_inset Flex Code
status collapsed status collapsed

View File

@ -1603,7 +1603,15 @@ BiblioInfo::CiteStringMap const BiblioInfo::getCiteStrings(
string style; string style;
CiteStringMap csm(styles.size()); CiteStringMap csm(styles.size());
for (size_t i = 0; i != csm.size(); ++i) { for (size_t i = 0; i != csm.size(); ++i) {
if (!styles[i].style.empty() && styles[i].style != buf.masterParams().biblatex_citestyle) bool ours = false;
// exclude variants that are not supported in the current style
for (string const & s: styles[i].styles) {
if (s == buf.masterParams().biblatex_citestyle) {
ours = true;
break;
}
}
if (!styles[i].styles.empty() && !ours)
continue; continue;
style = styles[i].name; style = styles[i].name;
csm[i] = make_pair(from_ascii(style), getLabel(keys, buf, style, ci)); csm[i] = make_pair(from_ascii(style), getLabel(keys, buf, style, ci));

View File

@ -43,8 +43,8 @@ public:
std::string stardesc; std::string stardesc;
/// Optional tooltip for the starred version /// Optional tooltip for the starred version
std::string startooltip; std::string startooltip;
/// Style that supports the command /// Styles that supports the command
std::string style; std::vector <std::string> styles;
/// upper casing author prefixes (van -> Van) /// upper casing author prefixes (van -> Van)
bool forceUpperCase; bool forceUpperCase;
/// starred version (full author list by default) /// starred version (full author list by default)

View File

@ -1228,7 +1228,7 @@ bool TextClass::readCiteEngine(Lexer & lexrc, ReadType rt, bool const add)
// split off style prefix if there // split off style prefix if there
if (contains(lyx_cmd, '@')) { if (contains(lyx_cmd, '@')) {
lyx_cmd = split(lyx_cmd, style, '@'); lyx_cmd = split(lyx_cmd, style, '@');
cs.style = style; cs.styles = getVectorFromString(style);
} }
cs.name = lyx_cmd; cs.name = lyx_cmd;
cs.cmd = latex_cmd.empty() ? lyx_cmd : latex_cmd; cs.cmd = latex_cmd.empty() ? lyx_cmd : latex_cmd;

View File

@ -1749,7 +1749,15 @@ void MenuDefinition::expandCiteStyles(BufferView const * bv)
for (int ii = 1; cit != end; ++cit, ++ii) { for (int ii = 1; cit != end; ++cit, ++ii) {
docstring label = cit->second; docstring label = cit->second;
CitationStyle ccs = citeStyleList[ii - 1]; CitationStyle ccs = citeStyleList[ii - 1];
if (!ccs.style.empty() && ccs.style != bp.biblatex_citestyle) bool ours = false;
// exclude variants that are not supported in the current style
for (string const & s: ccs.styles) {
if (s == bp.biblatex_citestyle) {
ours = true;
break;
}
}
if (!ccs.styles.empty() && !ours)
continue; continue;
ccs.forceUpperCase &= force; ccs.forceUpperCase &= force;
ccs.hasStarredVersion &= star; ccs.hasStarredVersion &= star;

View File

@ -380,7 +380,15 @@ CitationStyle asValidLatexCommand(BufferParams const & bp, string const & input,
for (; it != end; ++it) { for (; it != end; ++it) {
CitationStyle this_cs = *it; CitationStyle this_cs = *it;
if (this_cs.name == normalized_input) { if (this_cs.name == normalized_input) {
if (!this_cs.style.empty() && this_cs.style != bp.biblatex_citestyle) { bool ours = false;
// exclude variants that are not supported in the current style
for (string const & s: this_cs.styles) {
if (s == bp.biblatex_citestyle) {
ours = true;
break;
}
}
if (!this_cs.styles.empty() && !ours) {
// citation not supported with current style // citation not supported with current style
// reset to \cite // reset to \cite
normalized_input = "cite"; normalized_input = "cite";