#include "ColorSet.h"
#include "Converter.h"
#include "Encoding.h"
-#include "HSpace.h"
#include "IndicesList.h"
#include "Language.h"
#include "LaTeXFeatures.h"
#include "LaTeXFonts.h"
+#include "Length.h"
#include "ModuleList.h"
#include "Font.h"
#include "Lexer.h"
return false;
}
-} // anon namespace
+} // namespace
class BufferParams::Impl
IndicesList indiceslist;
Spacing spacing;
Length parindent;
+ Length mathindent;
/** This is the amount of space used for paragraph_separation "skip",
* and for detached paragraphs in "indented" documents.
*/
VSpace defskip;
- HSpace math_indentation;
PDFOptions pdfoptions;
LayoutFileIndex baseClass_;
FormatList exportableFormatList;
makeDocumentClass();
paragraph_separation = ParagraphIndentSeparation;
is_math_indent = false;
- math_indentation = "default";
+ math_numbering_side = DEFAULT;
quotes_style = InsetQuotesParams::EnglishQuotes;
dynamic_quotes = false;
fontsize = "default";
html_css_as_file = false;
display_pixel_ratio = 1.0;
+ shell_escape = false;
output_sync = false;
use_refstyle = true;
+ use_minted = false;
// map current author
author_map_[pimpl_->authorlist.get(0).bufferId()] = 0;
}
-HSpace const & BufferParams::getMathIndentation() const
+Length const & BufferParams::getMathIndent() const
{
- return pimpl_->math_indentation;
+ return pimpl_->mathindent;
}
-void BufferParams::setMathIndentation(HSpace const & indent)
+void BufferParams::setMathIndent(Length const & indent)
{
- pimpl_->math_indentation = indent;
+ pimpl_->mathindent = indent;
}
}
+BufferParams::MathNumber BufferParams::getMathNumber() const
+{
+ if (math_numbering_side != DEFAULT)
+ return math_numbering_side;
+ // FIXME: do not hardcode language here
+ else if (language->lang() == "arabic_arabi"
+ || documentClass().provides("leqno"))
+ return LEFT;
+ else
+ return RIGHT;
+}
+
+
string BufferParams::readToken(Lexer & lex, string const & token,
FileName const & filepath)
{
lex >> is_math_indent;
} else if (token == "\\math_indentation") {
lex.next();
- string math_indentation = lex.getString();
- pimpl_->math_indentation = HSpace(math_indentation);
+ string mathindent = lex.getString();
+ if (mathindent == "default")
+ pimpl_->mathindent = Length();
+ else
+ pimpl_->mathindent = Length(mathindent);
+ } else if (token == "\\math_numbering_side") {
+ string tmp;
+ lex >> tmp;
+ if (tmp == "left")
+ math_numbering_side = LEFT;
+ else if (tmp == "right")
+ math_numbering_side = RIGHT;
+ else
+ math_numbering_side = DEFAULT;
} else if (token == "\\quotes_style") {
string qstyle;
lex >> qstyle;
lex >> output_sync_macro;
} else if (token == "\\use_refstyle") {
lex >> use_refstyle;
+ } else if (token == "\\use_minted") {
+ lex >> use_minted;
} else {
lyxerr << "BufferParams::readToken(): Unknown token: " <<
token << endl;
return "\"" + str + "\"";
return str;
}
-}
+} // namespace
void BufferParams::writeFile(ostream & os, Buffer const * buf) const
<< "\n\\suppress_date " << convert<string>(suppress_date)
<< "\n\\justification " << convert<string>(justification)
<< "\n\\use_refstyle " << use_refstyle
+ << "\n\\use_minted " << use_minted
<< '\n';
if (isbackgroundcolor == true)
os << "\\backgroundcolor " << lyx::X11hexname(backgroundcolor) << '\n';
<< string_paragraph_separation[paragraph_separation];
if (!paragraph_separation)
os << "\n\\paragraph_indentation "
- << (pimpl_->parindent.empty() ? "default" : pimpl_->parindent.asString());
+ << (getParIndent().empty() ? "default" : getParIndent().asString());
else
os << "\n\\defskip " << getDefSkip().asLyXCommand();
os << "\n\\is_math_indent " << is_math_indent;
- if (is_math_indent && getMathIndentation().asLyXCommand() != "default")
- os << "\n\\math_indentation " << getMathIndentation().asLyXCommand();
+ if (is_math_indent)
+ os << "\n\\math_indentation "
+ << (getMathIndent().empty() ? "default" : getMathIndent().asString());
+ os << "\n\\math_numbering_side ";
+ switch(math_numbering_side) {
+ case LEFT:
+ os << "left";
+ break;
+ case RIGHT:
+ os << "right";
+ break;
+ case DEFAULT:
+ os << "default";
+ }
os << "\n\\quotes_style "
<< string_quotes_style[quotes_style]
<< "\n\\dynamic_quotes " << dynamic_quotes
if (useNonTeXFonts && fontsMath() != "auto")
features.require("unicode-math");
-
+
if (use_microtype)
features.require("microtype");
if (is_math_indent)
clsoptions << "fleqn,";
+ switch(math_numbering_side) {
+ case LEFT:
+ clsoptions << "leqno,";
+ break;
+ case RIGHT:
+ clsoptions << "reqno,";
+ features.require("amsmath");
+ break;
+ case DEFAULT:
+ break;
+ }
+
// language should be a parameter to \documentclass
if (language->babel() == "hebrew"
&& default_language->babel() != "hebrew")
if (is_math_indent) {
// when formula indentation
// only output something when it is not the default
- if (getMathIndentation().asLyXCommand() != "default") {
+ if (!getMathIndent().empty()) {
os << "\\setlength{\\mathindent}{"
- << from_utf8(getMathIndentation().asLatexCommand())
+ << from_utf8(getMathIndent().asString())
<< "}\n";
}
}
// http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg144349.html
os << from_ascii(features.getColorOptions());
- // If we use hyperref, jurabib, japanese, varioref or vietnamese,
+ // If we use hyperref, jurabib, japanese or varioref,
// we have to call babel before
if (use_babel
&& (features.isRequired("jurabib")
|| features.isRequired("hyperref")
|| features.isRequired("varioref")
- || features.isRequired("vietnamese")
|| features.isRequired("japanese"))) {
os << features.getBabelPresettings();
// FIXME UNICODE
// called after babel, though.
if (use_babel && !features.isRequired("jurabib")
&& !features.isRequired("hyperref")
- && !features.isRequired("varioref")
- && !features.isRequired("vietnamese")
+ && !features.isRequired("varioref")
&& !features.isRequired("japanese")) {
os << features.getBabelPresettings();
// FIXME UNICODE
}
if (features.isRequired("bicaption"))
os << "\\usepackage{bicaption}\n";
- if (!listings_params.empty() || features.mustProvide("listings"))
- os << "\\usepackage{listings}\n";
+ if (!listings_params.empty()
+ || features.mustProvide("listings")
+ || features.mustProvide("minted")) {
+ if (features.mustProvide("listings"))
+ os << "\\usepackage{listings}\n";
+ else
+ os << "\\usepackage{minted}\n";
+ }
if (!listings_params.empty()) {
- os << "\\lstset{";
+ if (features.mustProvide("listings"))
+ os << "\\lstset{";
+ else
+ os << "\\setminted{";
// do not test validity because listings_params is
// supposed to be valid
string par =
// (the rest is obsoleted by the new TU encoding).
// It needs to be loaded at least after amsmath, amssymb,
// esint and the other packages that provide special glyphs
- if (features.mustProvide("tipa") && useNonTeXFonts) {
+ if (features.mustProvide("tipa") && useNonTeXFonts
+ && !features.isProvided("xunicode")) {
// The package officially only supports XeTeX, but also works
// with LuaTeX. Thus we work around its XeTeX test.
if (features.runparams().flavor != OutputParams::XETEX) {
}
docstring const i18npreamble =
- features.getTClassI18nPreamble(use_babel, use_polyglossia);
+ features.getTClassI18nPreamble(use_babel, use_polyglossia,
+ use_minted);
if (!i18npreamble.empty())
os << i18npreamble + '\n';
{
FormatList & cached = only_viewable ?
pimpl_->viewableFormatList : pimpl_->exportableFormatList;
- bool & valid = only_viewable ?
+ bool & valid = only_viewable ?
pimpl_->isViewCacheValid : pimpl_->isExportCacheValid;
if (valid)
return cached;
theConverters().getReachable(backs[0], only_viewable, true, excludes);
for (vector<string>::const_iterator it = backs.begin() + 1;
it != backs.end(); ++it) {
- FormatList r = theConverters().getReachable(*it, only_viewable,
+ FormatList r = theConverters().getReachable(*it, only_viewable,
false, excludes);
result.insert(result.end(), r.begin(), r.end());
}
v.push_back("luatex");
v.push_back("dviluatex");
}
- } else
- v.push_back(buffmt);
+ } else {
+ string rbuffmt = buffmt;
+ // If we use an OutputFormat in Japanese docs,
+ // we need special format in order to get the path
+ // via pLaTeX (#8823)
+ if (documentClass().hasOutputFormat()
+ && encoding().package() == Encoding::japanese)
+ rbuffmt += "-ja";
+ v.push_back(rbuffmt);
+ }
v.push_back("xhtml");
v.push_back("text");
if (find(backs.begin(), backs.end(), dformat) == backs.end()) {
// Get shortest path to format
Graph::EdgePath path;
- for (vector<string>::const_iterator it = backs.begin();
- it != backs.end(); ++it) {
- Graph::EdgePath p = theConverters().getPath(*it, dformat);
+ for (auto const & bvar : backs) {
+ Graph::EdgePath p = theConverters().getPath(bvar, dformat);
if (!p.empty() && (path.empty() || p.size() < path.size())) {
path = p;
}
if (!default_output_format.empty()
&& default_output_format != "default")
return default_output_format;
- if (isDocBook()
- || encoding().package() == Encoding::japanese) {
+ if (isDocBook()) {
FormatList const & formats = exportableFormats(true);
if (formats.empty())
return string();
// return the first we find
return formats.front()->name();
}
+ if (encoding().package() == Encoding::japanese)
+ return lyxrc.default_platex_view_format;
if (useNonTeXFonts)
return lyxrc.default_otf_view_format;
return lyxrc.default_view_format;
language->encoding()->package();
// Create list of inputenc options:
- set<string> encodings;
+ set<string> encoding_set;
// luainputenc fails with more than one encoding
if (!features.runparams().isFullUnicode()) // if we reach this point, this means LuaTeX with TeX fonts
// list all input encodings used in the document
- encodings = features.getEncodingSet(doc_encoding);
+ encoding_set = features.getEncodingSet(doc_encoding);
// If the "japanese" package (i.e. pLaTeX) is used,
// inputenc must be omitted.
// see http://www.mail-archive.com/lyx-devel@lists.lyx.org/msg129680.html
- if ((!encodings.empty() || package == Encoding::inputenc)
+ if ((!encoding_set.empty() || package == Encoding::inputenc)
&& !features.isRequired("japanese")
&& !features.isProvided("inputenc")) {
os << "\\usepackage[";
- set<string>::const_iterator it = encodings.begin();
- set<string>::const_iterator const end = encodings.end();
+ set<string>::const_iterator it = encoding_set.begin();
+ set<string>::const_iterator const end = encoding_set.end();
if (it != end) {
os << from_ascii(*it);
++it;
for (; it != end; ++it)
os << ',' << from_ascii(*it);
if (package == Encoding::inputenc) {
- if (!encodings.empty())
+ if (!encoding_set.empty())
os << ',';
os << from_ascii(doc_encoding);
}
Encoding const & BufferParams::encoding() const
{
// Main encoding for LaTeX output.
- //
+ //
// Exception: XeTeX with 8-bit TeX fonts requires ASCII (see #9740).
// As the "flavor" is only known once export started, this
// cannot be handled here. Instead, runparams.encoding is set