mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Extend flexible version check to packages
This commit is contained in:
parent
029adfa28c
commit
2e6ea5f613
@ -120,34 +120,19 @@
|
|||||||
#6
|
#6
|
||||||
\fi}
|
\fi}
|
||||||
|
|
||||||
% Tests whether an package is present in a specific version (or newer)
|
% Tests whether an package is present and also adds the version to the package list
|
||||||
% Syntax: \TestPackageVersion{<name>}{<yyyy/mm/dd>}
|
\newcommand{\TestPackageAddVersion}[2][\default]{
|
||||||
|
\def\default{#2}
|
||||||
\newcommand{\TestPackageVersion}[2]{
|
\def\package@version{}
|
||||||
% The actual test only works if the package has been loaded before
|
% The actual test only works after the package has been loaded
|
||||||
\IfFileExists{#1.sty}{\RequirePackage{#1}}{}
|
\IfFileExists{#1.sty}{%
|
||||||
\@TestPackageVersion{#1}{#2}
|
\RequirePackage{#1}%
|
||||||
|
\protected@edef\package@@version{\csname ver@#1.sty\endcsname}%
|
||||||
|
\protected@edef\package@version{\expandafter\@parse@version\package@@version//00\@nil}%
|
||||||
|
}{}
|
||||||
|
\TestItem[#1]{#2}{package}{sty}{\AddPackage[\package@version]{#2}}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
\newcommand{\@TestPackageVersion}[2]{
|
|
||||||
\message{^^J\prefix checking for package #1 at least as of #2...}
|
|
||||||
\IfFileExists{#1.sty}
|
|
||||||
{
|
|
||||||
\@ifpackagelater{#1}{#2}{\existstrue}{\existsfalse}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
\existsfalse
|
|
||||||
}
|
|
||||||
\ifexists
|
|
||||||
\message{yes^^J}
|
|
||||||
\AddVariable{#1}{yes}
|
|
||||||
\AddPackage{#1-#2}
|
|
||||||
\else
|
|
||||||
\message{no^^J}
|
|
||||||
\AddVariable{#1}{no}
|
|
||||||
\fi}
|
|
||||||
|
|
||||||
|
|
||||||
% Adapted from ltxcheck.tex
|
% Adapted from ltxcheck.tex
|
||||||
\newcommand{\TestFont}[2][\default]{
|
\newcommand{\TestFont}[2][\default]{
|
||||||
\def\default{#2}
|
\def\default{#2}
|
||||||
@ -222,7 +207,7 @@
|
|||||||
\AddVariable{fmtversion}{\fmtversion}
|
\AddVariable{fmtversion}{\fmtversion}
|
||||||
|
|
||||||
%%% Store the current LaTeX version
|
%%% Store the current LaTeX version
|
||||||
\AddPackage[\fmtversion]{LaTeX}
|
\AddPackage[\expandafter\@parse@version\fmtversion//00\@nil]{LaTeX}
|
||||||
|
|
||||||
%%% And now, the list of available languages
|
%%% And now, the list of available languages
|
||||||
% The trick is to know that \the\everyjob contains something like
|
% The trick is to know that \the\everyjob contains something like
|
||||||
@ -307,7 +292,7 @@
|
|||||||
\TestPackage{array}
|
\TestPackage{array}
|
||||||
\TestPackage{astron}
|
\TestPackage{astron}
|
||||||
\TestPackage{authordate1-4}
|
\TestPackage{authordate1-4}
|
||||||
\TestPackage{babel}
|
\TestPackageAddVersion{babel}
|
||||||
\TestPackage{beamerposter}
|
\TestPackage{beamerposter}
|
||||||
\TestPackage{biblatex}
|
\TestPackage{biblatex}
|
||||||
\TestPackage{biblatex-chicago}
|
\TestPackage{biblatex-chicago}
|
||||||
@ -356,7 +341,7 @@
|
|||||||
\TestPackage[iso-8859-7.def]{greek-inputenc}
|
\TestPackage[iso-8859-7.def]{greek-inputenc}
|
||||||
\TestPackage{harvard}
|
\TestPackage{harvard}
|
||||||
\TestPackage{hhline}
|
\TestPackage{hhline}
|
||||||
\TestPackage{hyperref}
|
\TestPackageAddVersion{hyperref}
|
||||||
\TestPackage{hyphenat}
|
\TestPackage{hyphenat}
|
||||||
\TestPackage{iftex}
|
\TestPackage{iftex}
|
||||||
\TestPackage{ifthen}
|
\TestPackage{ifthen}
|
||||||
@ -378,7 +363,7 @@
|
|||||||
\TestPackage{mhchem}
|
\TestPackage{mhchem}
|
||||||
\TestPackage[mongolian.ldf]{mongolian}
|
\TestPackage[mongolian.ldf]{mongolian}
|
||||||
\TestPackage{mslapa}
|
\TestPackage{mslapa}
|
||||||
\TestPackage{multirow}
|
\TestPackageAddVersion{multirow}
|
||||||
\TestPackage{named}
|
\TestPackage{named}
|
||||||
\TestPackage{natbib}
|
\TestPackage{natbib}
|
||||||
\TestPackage{nicefrac}
|
\TestPackage{nicefrac}
|
||||||
@ -416,6 +401,7 @@
|
|||||||
\TestPackage{thswitch}
|
\TestPackage{thswitch}
|
||||||
\TestPackage{tikz}
|
\TestPackage{tikz}
|
||||||
\TestPackage[turkmen.ldf]{turkmen}
|
\TestPackage[turkmen.ldf]{turkmen}
|
||||||
|
\TestPackageAddVersion{ucs}
|
||||||
\TestPackage{ulem}
|
\TestPackage{ulem}
|
||||||
\TestPackage{undertilde}
|
\TestPackage{undertilde}
|
||||||
\TestPackage{unicode-math}
|
\TestPackage{unicode-math}
|
||||||
@ -562,18 +548,6 @@
|
|||||||
%\TestPackage{mathabx}
|
%\TestPackage{mathabx}
|
||||||
%\TestPackage{mathdesign}% But see above!
|
%\TestPackage{mathdesign}% But see above!
|
||||||
|
|
||||||
%%% Specific package versions
|
|
||||||
% This introduces \babelfonts
|
|
||||||
\TestPackageVersion{babel}{2017/11/03}
|
|
||||||
% This introduces multiple paragraphs in multirows
|
|
||||||
\TestPackageVersion{multirow}{2021/01/29}
|
|
||||||
% With this version, hyperref option unicode is true
|
|
||||||
% by default
|
|
||||||
\TestPackageVersion{hyperref}{2021/02/04}
|
|
||||||
% As of this version, the ucs package must be explicitly
|
|
||||||
% loaded to get utf8x (rather than utf8) encoding tables
|
|
||||||
\TestPackageVersion{ucs}{2022/08/07}
|
|
||||||
|
|
||||||
%%% Document classes
|
%%% Document classes
|
||||||
% The list of layout files has been put in this file here by the
|
% The list of layout files has been put in this file here by the
|
||||||
% configure script.
|
% configure script.
|
||||||
|
@ -1922,7 +1922,7 @@ bool BufferParams::writeLaTeX(otexstream & os, LaTeXFeatures & features,
|
|||||||
if (useNonTeXFonts) {
|
if (useNonTeXFonts) {
|
||||||
// Babel (as of 2017/11/03) loads fontspec itself
|
// Babel (as of 2017/11/03) loads fontspec itself
|
||||||
if (!features.isProvided("fontspec")
|
if (!features.isProvided("fontspec")
|
||||||
&& !(features.useBabel() && features.isAvailable("babel-2017/11/03")))
|
&& !(features.useBabel() && features.isAvailableAtLeastFrom("babel", 2017, 11, 3)))
|
||||||
os << "\\usepackage{fontspec}\n";
|
os << "\\usepackage{fontspec}\n";
|
||||||
if (features.mustProvide("unicode-math")
|
if (features.mustProvide("unicode-math")
|
||||||
&& features.isAvailable("unicode-math"))
|
&& features.isAvailable("unicode-math"))
|
||||||
@ -3448,7 +3448,7 @@ void BufferParams::writeEncodingPreamble(otexstream & os,
|
|||||||
// Thus we load ucs.sty in order to keep functionality
|
// Thus we load ucs.sty in order to keep functionality
|
||||||
// that would otherwise be silently dropped.
|
// that would otherwise be silently dropped.
|
||||||
if (doc_encoding == "utf8x"
|
if (doc_encoding == "utf8x"
|
||||||
&& features.isAvailable("ucs-2022/08/07")
|
&& features.isAvailableAtLeastFrom("ucs", 2022, 8, 7)
|
||||||
&& !features.isProvided("ucs"))
|
&& !features.isProvided("ucs"))
|
||||||
os << "\\usepackage{ucs}\n";
|
os << "\\usepackage{ucs}\n";
|
||||||
os << "\\usepackage[" << doc_encoding << "]{"
|
os << "\\usepackage[" << doc_encoding << "]{"
|
||||||
@ -3507,7 +3507,7 @@ string const BufferParams::loadFonts(LaTeXFeatures & features) const
|
|||||||
// As of 2017/11/03, Babel has its own higher-level
|
// As of 2017/11/03, Babel has its own higher-level
|
||||||
// interface on top of fontspec that is to be used.
|
// interface on top of fontspec that is to be used.
|
||||||
bool const babelfonts = features.useBabel()
|
bool const babelfonts = features.useBabel()
|
||||||
&& features.isAvailable("babel-2017/11/03");
|
&& features.isAvailableAtLeastFrom("babel", 2017, 11, 3);
|
||||||
string const texmapping =
|
string const texmapping =
|
||||||
(features.runparams().flavor == Flavor::XeTeX) ?
|
(features.runparams().flavor == Flavor::XeTeX) ?
|
||||||
"Mapping=tex-text" : "Ligatures=TeX";
|
"Mapping=tex-text" : "Ligatures=TeX";
|
||||||
|
@ -62,7 +62,7 @@ void LaTeXPackages::getAvailable()
|
|||||||
string const p = lex.getString();
|
string const p = lex.getString();
|
||||||
// Parse optional version info
|
// Parse optional version info
|
||||||
lex.eatLine();
|
lex.eatLine();
|
||||||
string const v = lex.getString();
|
string const v = trim(lex.getString());
|
||||||
packages_.insert(make_pair(p, v));
|
packages_.insert(make_pair(p, v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,8 +92,8 @@ bool LaTeXPackages::isAvailableAtLeastFrom(string const & name,
|
|||||||
getAvailable();
|
getAvailable();
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
// Check for yyyy-mm-dd
|
// Check for yyyy[-/]mm[-/]dd
|
||||||
static regex const reg("([\\d]{4})-([\\d]{2})-([\\d]{2})");
|
static regex const reg("([\\d]{4})[-/]?([\\d]{2})[-/]?([\\d]{2})");
|
||||||
for (auto const & package : packages_) {
|
for (auto const & package : packages_) {
|
||||||
if (package.first == name && !package.second.empty()) {
|
if (package.first == name && !package.second.empty()) {
|
||||||
smatch sub;
|
smatch sub;
|
||||||
|
@ -108,7 +108,7 @@ void PDFOptions::writeLaTeX(OutputParams & runparams, otexstream & os,
|
|||||||
// Since LyX uses unicode, also set the PDF strings to unicode strings
|
// Since LyX uses unicode, also set the PDF strings to unicode strings
|
||||||
// with the hyperref option "unicode". This is only needed with pdflatex.
|
// with the hyperref option "unicode". This is only needed with pdflatex.
|
||||||
// As of 2021/02/04, unicode=true is default.
|
// As of 2021/02/04, unicode=true is default.
|
||||||
if (!LaTeXFeatures::isAvailable("hyperref-2021/02/04")
|
if (!LaTeXFeatures::isAvailableAtLeastFrom("hyperref", 2021, 2, 4)
|
||||||
&& !runparams.isFullUnicode() && !runparams.use_japanese)
|
&& !runparams.isFullUnicode() && !runparams.use_japanese)
|
||||||
opt += "unicode=true,";
|
opt += "unicode=true,";
|
||||||
|
|
||||||
|
@ -3272,7 +3272,7 @@ void Tabular::TeXRow(otexstream & os, row_type row,
|
|||||||
} else if (!isPartOfMultiRow(row, c)) {
|
} else if (!isPartOfMultiRow(row, c)) {
|
||||||
if (!runparams.nice)
|
if (!runparams.nice)
|
||||||
os.texrow().start(par.id(), 0);
|
os.texrow().start(par.id(), 0);
|
||||||
if (isMultiRow(cell) && !LaTeXFeatures::isAvailable("multirow-2021/01/29"))
|
if (isMultiRow(cell) && !LaTeXFeatures::isAvailableAtLeastFrom("multirow", 2021, 1, 29))
|
||||||
newrp.isNonLong = true;
|
newrp.isNonLong = true;
|
||||||
inset->latex(os, newrp);
|
inset->latex(os, newrp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user