mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 23:15:19 +00:00
Generalize the protection of brackets in citation arguments
Whenever an argument delimiter is used inside the argument, the argument needs to be grouped, that is \cites({text (text) text}) or \cite[{text [text] text}] This fixes the original case reported in #2751 which is independent from the general issue that the pre- and postnote field take literal code.
This commit is contained in:
parent
1265ed2a68
commit
efca146571
@ -226,6 +226,15 @@ inline docstring wrapCitation(docstring const & key,
|
||||
html::htmlize(content, XHTMLStream::ESCAPE_ALL) + "</a>";
|
||||
}
|
||||
|
||||
|
||||
docstring protectArgument(docstring & arg)
|
||||
{
|
||||
if (contains(arg, '[') || contains(arg, ']'))
|
||||
// protect brackets
|
||||
arg = '{' + arg + '}';
|
||||
return arg;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
docstring InsetCitation::generateLabel(bool for_xhtml) const
|
||||
@ -422,12 +431,13 @@ void InsetCitation::latex(otexstream & os, OutputParams const & runparams) const
|
||||
|
||||
os << "\\" << cite_str;
|
||||
|
||||
docstring const & before = getParam("before");
|
||||
docstring const & after = getParam("after");
|
||||
docstring before = getParam("before");
|
||||
docstring after = getParam("after");
|
||||
if (!before.empty() && cs.textBefore)
|
||||
os << '[' << before << "][" << after << ']';
|
||||
os << '[' << protectArgument(before)
|
||||
<< "][" << protectArgument(after) << ']';
|
||||
else if (!after.empty() && cs.textAfter)
|
||||
os << '[' << after << ']';
|
||||
os << '[' << protectArgument(after) << ']';
|
||||
|
||||
if (!bi.isBibtex(getParam("key")))
|
||||
// escape chars with bibitems
|
||||
|
@ -122,6 +122,10 @@ What's new
|
||||
- Fix mathtools, amsmath and amssymb not loading automatically for some
|
||||
symbols (bug 10467)
|
||||
|
||||
- Protect citation arguments (pre and post text) which contain brackets
|
||||
(part of bug 2751).
|
||||
|
||||
|
||||
* LYX2LYX
|
||||
|
||||
- Do not convert "--" to "\twohyphens" in formula macros.
|
||||
|
Loading…
Reference in New Issue
Block a user