mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-10 18:58:10 +00:00
Improve tex2lyx for style-specific biblatex citation commands
This commit is contained in:
parent
55d60ee24f
commit
723a38be35
@ -84,6 +84,8 @@ public:
|
|||||||
///
|
///
|
||||||
void citeEngine(std::string const & e) { h_cite_engine = e; }
|
void citeEngine(std::string const & e) { h_cite_engine = e; }
|
||||||
///
|
///
|
||||||
|
std::string biblatexCiteStyle() const { return h_biblatex_citestyle; }
|
||||||
|
///
|
||||||
std::string multibib() const { return h_multibib; }
|
std::string multibib() const { return h_multibib; }
|
||||||
///
|
///
|
||||||
void multibib(std::string const & s) { h_multibib = s; }
|
void multibib(std::string const & s) { h_multibib = s; }
|
||||||
|
@ -209,13 +209,17 @@ char const * const known_jurabib_commands[] = { "cite", "citet", "citep",
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* biblatex commands.
|
* biblatex commands.
|
||||||
* Known starred forms: \cite*, \citeauthor*, \Citeauthor*, \parencite*, \citetitle*.
|
|
||||||
*/
|
*/
|
||||||
char const * const known_biblatex_commands[] = { "cite", "Cite", "textcite", "Textcite",
|
char const * const known_biblatex_commands[] = { "cite", "Cite", "textcite", "Textcite",
|
||||||
"parencite", "Parencite", "citeauthor", "Citeauthor", "citeyear", "smartcite", "Smartcite",
|
"parencite", "Parencite", "citeauthor", "Citeauthor", "citeyear", "smartcite", "Smartcite",
|
||||||
"footcite", "Footcite", "autocite", "Autocite", "citetitle", "fullcite", "footfullcite",
|
"footcite", "Footcite", "autocite", "Autocite", "citetitle", "fullcite", "footfullcite",
|
||||||
"supercite", "cites", "Cites", "textcites", "Textcites", "parencites", "Parencites",
|
"supercite", "cites", "Cites", "textcites", "Textcites", "parencites", "Parencites",
|
||||||
"smartcites", "Smartcites", "autocites", "Autocites", "nptextcite", 0 };
|
"smartcites", "Smartcites", "autocites", "Autocites", 0 };
|
||||||
|
/*!
|
||||||
|
* Known starred biblatex commands.
|
||||||
|
*/
|
||||||
|
char const * const known_biblatex_star_commands[] = { "cite", "citeauthor",
|
||||||
|
"Citeauthor", "parencite", "citetitle", 0 };
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* biblatex-chicago commands.
|
* biblatex-chicago commands.
|
||||||
@ -4692,25 +4696,31 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((use_biblatex
|
if ((use_biblatex// normal biblatex
|
||||||
&& is_known(t.cs(), known_biblatex_commands)
|
&& is_known(t.cs(), known_biblatex_commands)
|
||||||
&& ((t.cs() == "cite"
|
&& (is_known(t.cs(), known_biblatex_star_commands)
|
||||||
|| t.cs() == "citeauthor"
|
|
||||||
|| t.cs() == "Citeauthor"
|
|
||||||
|| t.cs() == "parencite"
|
|
||||||
|| t.cs() == "citetitle")
|
|
||||||
|| p.next_token().asInput() != "*"))
|
|| p.next_token().asInput() != "*"))
|
||||||
|| (use_biblatex_natbib
|
|| (use_biblatex_natbib// biblatex-natbib
|
||||||
&& (is_known(t.cs(), known_biblatex_commands)
|
&& (is_known(t.cs(), known_biblatex_commands)
|
||||||
|| is_known(t.cs(), known_natbib_commands))
|
|| is_known(t.cs(), known_natbib_commands))
|
||||||
&& ((t.cs() == "cite" || t.cs() == "citet" || t.cs() == "Citet"
|
&& (is_known(t.cs(), known_biblatex_star_commands)
|
||||||
|| t.cs() == "Citealt" || t.cs() == "citealp" || t.cs() == "Citealp"
|
|| (t.cs() == "citet" || t.cs() == "Citet"
|
||||||
|| t.cs() == "citeauthor" || t.cs() == "Citeauthor"
|
|| t.cs() == "Citealt" || t.cs() == "citealp"
|
||||||
|| t.cs() == "parencite" || t.cs() == "citetitle")
|
|| t.cs() == "Citealp")
|
||||||
|| p.next_token().asInput() != "*"))
|
|| p.next_token().asInput() != "*"))
|
||||||
|| (use_biblatex_chicago
|
|| (use_biblatex_chicago// biblatex-chicago
|
||||||
&& (is_known(t.cs(), known_biblatex_commands)
|
&& (is_known(t.cs(), known_biblatex_commands)
|
||||||
|| is_known(t.cs(), known_biblatex_chicago_commands)))){
|
|| is_known(t.cs(), known_biblatex_chicago_commands))
|
||||||
|
&& (is_known(t.cs(), known_biblatex_star_commands)
|
||||||
|
|| p.next_token().asInput() != "*"))
|
||||||
|
|| ((use_biblatex || use_biblatex_natbib)// specific styles: apa, mla
|
||||||
|
&& ((prefixIs(preamble.biblatexCiteStyle(), "apa")
|
||||||
|
&& (t.cs() == "nptextcite" || t.cs() == "nptextcites"))
|
||||||
|
|| (prefixIs(preamble.biblatexCiteStyle(), "mla")
|
||||||
|
&& ((t.cs() == "headlesscite" && p.next_token().asInput() != "*")
|
||||||
|
|| t.cs() == "autocite" || t.cs() == "Autocite"
|
||||||
|
|| t.cs() == "autocites" || t.cs() == "Autocites"))))){
|
||||||
|
|
||||||
context.check_layout(os);
|
context.check_layout(os);
|
||||||
string command = t.cs();
|
string command = t.cs();
|
||||||
if (p.next_token().asInput() == "*") {
|
if (p.next_token().asInput() == "*") {
|
||||||
@ -4729,7 +4739,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
get_cite_arguments(p, true, before, after, qualified);
|
get_cite_arguments(p, true, before, after, qualified);
|
||||||
|
|
||||||
// These use natbib cmd names in LyX
|
// These use natbib cmd names in LyX
|
||||||
// for inter-citeengine compativility
|
// for inter-citeengine compatibility
|
||||||
if (command == "citeyear")
|
if (command == "citeyear")
|
||||||
command = "citebyear";
|
command = "citebyear";
|
||||||
else if (command == "cite*")
|
else if (command == "cite*")
|
||||||
@ -4749,6 +4759,16 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
|
|||||||
else if (command == "Smartcite")
|
else if (command == "Smartcite")
|
||||||
command = "Footcite";
|
command = "Footcite";
|
||||||
|
|
||||||
|
// MLA-specific commands
|
||||||
|
if (prefixIs(preamble.biblatexCiteStyle(), "mla")) {
|
||||||
|
if (prefixIs(command, "autocite"))
|
||||||
|
command = "mla" + command;
|
||||||
|
else if (prefixIs(command, "Autocite"))
|
||||||
|
command = subst(command, "Auto", "Mlaauto");
|
||||||
|
else if (command == "headlesscite")
|
||||||
|
command = "autocite*";
|
||||||
|
}
|
||||||
|
|
||||||
string const emptyarg = qualified ? "()" : "[]";
|
string const emptyarg = qualified ? "()" : "[]";
|
||||||
if (before.empty() && after == emptyarg)
|
if (before.empty() && after == emptyarg)
|
||||||
// avoid \cite[]{a}
|
// avoid \cite[]{a}
|
||||||
|
Loading…
Reference in New Issue
Block a user