mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Add Provides tag to languages
This allows to specify macros that are provided by specific (Babel) languages (such as \textgreek)
This commit is contained in:
parent
ab4bd6b77e
commit
71f0dd3a7f
@ -26,6 +26,7 @@
|
||||
# <extra latex code inserted after babel>
|
||||
# EndPostBabelPreamble
|
||||
# Requires <requirement>
|
||||
# Provides <feature>
|
||||
# End
|
||||
#
|
||||
#
|
||||
@ -167,6 +168,7 @@ Language ancientgreek
|
||||
InternalEncoding true
|
||||
FontEncoding LGR
|
||||
LangCode grc_GR
|
||||
Provides textgreek
|
||||
End
|
||||
|
||||
# FIXME: dummy babel language for arabic_arabtex to be able
|
||||
@ -618,6 +620,7 @@ Language greek
|
||||
InternalEncoding true
|
||||
FontEncoding LGR
|
||||
LangCode el_GR
|
||||
Provides textgreek
|
||||
End
|
||||
|
||||
Language polutonikogreek
|
||||
@ -630,6 +633,7 @@ Language polutonikogreek
|
||||
InternalEncoding true
|
||||
FontEncoding LGR
|
||||
LangCode el_GR
|
||||
Provides textgreek
|
||||
End
|
||||
|
||||
Language hebrew
|
||||
|
@ -544,6 +544,12 @@ void LaTeXFeatures::require(set<string> const & names)
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::provide(string const & name)
|
||||
{
|
||||
provides_.insert(name);
|
||||
}
|
||||
|
||||
|
||||
void LaTeXFeatures::useLayout(docstring const & layoutname)
|
||||
{
|
||||
useLayout(layoutname, 0);
|
||||
@ -609,19 +615,11 @@ bool LaTeXFeatures::isRequired(string const & name) const
|
||||
|
||||
bool LaTeXFeatures::isProvided(string const & name) const
|
||||
{
|
||||
// \textgreek is provided by babel globally if a Greek language/variety
|
||||
// is used in the document
|
||||
if (useBabel() && name == "textgreek"
|
||||
&& params_.main_font_encoding() != "default") {
|
||||
// get main font encodings
|
||||
vector<string> fontencs = params_.font_encodings();
|
||||
// get font encodings of secondary languages
|
||||
getFontEncodings(fontencs, true);
|
||||
for (auto & fe : fontencs) {
|
||||
if (!Encodings::needsScriptWrapper(name, fe))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// \textgreek is provided by babel globally if a Greek
|
||||
// language/variety is used in the document
|
||||
if (provides_.find(name) != provides_.end())
|
||||
return true;
|
||||
|
||||
// FIXME: Analoguously, babel provides a command \textcyrillic, but
|
||||
// for some reason, we roll our own \textcyr definition
|
||||
// We should use \textcyrillic instead and only define it
|
||||
@ -756,6 +754,9 @@ void LaTeXFeatures::useLanguage(Language const * lang)
|
||||
UsedLanguages_.insert(lang);
|
||||
if (!lang->requires().empty())
|
||||
require(lang->requires());
|
||||
// currently only supported for Babel
|
||||
if (!lang->provides().empty() && useBabel())
|
||||
provide(lang->provides());
|
||||
// CJK languages do not have a babel name.
|
||||
// They use the CJK package
|
||||
if (lang->encoding()->package() == Encoding::CJK)
|
||||
|
@ -103,6 +103,8 @@ public:
|
||||
void require(std::string const & name);
|
||||
/// Add a set of feature names requirements
|
||||
void require(std::set<std::string> const & names);
|
||||
/// Add a feature name provision
|
||||
void provide(std::string const & name);
|
||||
/// Is the (required) package available?
|
||||
static bool isAvailable(std::string const & name);
|
||||
/// Has the package been required?
|
||||
@ -186,10 +188,12 @@ private:
|
||||
std::list<docstring> usedLayouts_;
|
||||
///
|
||||
std::list<docstring> usedInsetLayouts_;
|
||||
/// The features that are needed by the document
|
||||
typedef std::set<std::string> Features;
|
||||
///
|
||||
typedef std::set<std::string> Features;
|
||||
/// The features that are needed by the document
|
||||
Features features_;
|
||||
/// Features that are provided
|
||||
Features provides_;
|
||||
/// Static preamble bits, from external templates, or anywhere else
|
||||
typedef std::list<TexString> SnippetList;
|
||||
///
|
||||
|
@ -87,9 +87,10 @@ bool Language::readLanguage(Lexer & lex)
|
||||
LA_POLYGLOSSIANAME,
|
||||
LA_POLYGLOSSIAOPTS,
|
||||
LA_POSTBABELPREAMBLE,
|
||||
LA_QUOTESTYLE,
|
||||
LA_PREBABELPREAMBLE,
|
||||
LA_PROVIDES,
|
||||
LA_REQUIRES,
|
||||
LA_QUOTESTYLE,
|
||||
LA_RTL
|
||||
};
|
||||
|
||||
@ -109,6 +110,7 @@ bool Language::readLanguage(Lexer & lex)
|
||||
{ "polyglossiaopts", LA_POLYGLOSSIAOPTS },
|
||||
{ "postbabelpreamble", LA_POSTBABELPREAMBLE },
|
||||
{ "prebabelpreamble", LA_PREBABELPREAMBLE },
|
||||
{ "provides", LA_PROVIDES },
|
||||
{ "quotestyle", LA_QUOTESTYLE },
|
||||
{ "requires", LA_REQUIRES },
|
||||
{ "rtl", LA_RTL }
|
||||
@ -184,6 +186,9 @@ bool Language::readLanguage(Lexer & lex)
|
||||
case LA_REQUIRES:
|
||||
lex >> requires_;
|
||||
break;
|
||||
case LA_PROVIDES:
|
||||
lex >> provides_;
|
||||
break;
|
||||
case LA_RTL:
|
||||
lex >> rightToLeft_;
|
||||
break;
|
||||
|
@ -50,6 +50,8 @@ public:
|
||||
std::string const quoteStyle() const { return quote_style_; }
|
||||
/// requirement (package, function)
|
||||
std::string const requires() const { return requires_; }
|
||||
/// provides feature
|
||||
std::string const provides() const { return provides_; }
|
||||
/// translatable GUI name
|
||||
std::string const display() const { return display_; }
|
||||
/// is this a RTL language?
|
||||
@ -109,6 +111,8 @@ private:
|
||||
///
|
||||
trivstring requires_;
|
||||
///
|
||||
trivstring provides_;
|
||||
///
|
||||
trivstring display_;
|
||||
///
|
||||
bool rightToLeft_;
|
||||
|
Loading…
Reference in New Issue
Block a user