Inset::DisplayType InsetListings::display() const
{
- return params().isInline() || params().isFloat() ? Inline : AlignLeft;
+ return params().isInline() || params().isFloat() ? Inline : Display | AlignLeft;
}
Encoding const * InsetListings::forcedEncoding(Encoding const * inner_enc,
- Encoding const * outer_enc) const
+ Encoding const * outer_enc) const
{
// The listings package cannot deal with multi-byte-encoded
// glyphs, except if full-unicode aware backends
param_string = getStringFromVector(opts, ",");
}
// Minted needs a language specification
- if (minted_language.empty())
- minted_language = "TeX";
+ if (minted_language.empty()) {
+ // If a language has been set globally, use that,
+ // otherwise use TeX by default
+ string const & blp = buffer().params().listings_params;
+ size_t start = blp.find("language=");
+ if (start != string::npos) {
+ start += strlen("language=");
+ size_t len = blp.find(",", start);
+ if (len != string::npos)
+ len -= start;
+ minted_language = blp.substr(start, len);
+ } else
+ minted_language = "TeX";
+ }
// get the paragraphs. We can not output them directly to given odocstream
// because we can not yet determine the delimiter character of \lstinline
// the restrictions of the listings package (see above).
// This needs to be consistent with
// LaTeXFeatures::getTClassI18nPreamble().
+ // We need to put this into a group in order to prevent encoding leaks
+ // (happens with cprotect).
+ os << "\\bgroup";
switchEncoding(os.os(), buffer().params(), runparams, *fixedlstenc, true);
runparams.encoding = fixedlstenc;
encoding_switched = true;
&& par->getInset(0)->lyxCode() == CAPTION_CODE;
while (par != end) {
- pos_type siz = par->size();
+ pos_type const siz = par->size();
bool captionline = false;
for (pos_type i = 0; i < siz; ++i) {
if (i == 0 && par->isInset(i) && i + 1 == siz)
if (encoding_switched){
// Switch back
- switchEncoding(os.os(), buffer().params(), runparams, *save_enc, true);
+ switchEncoding(os.os(), buffer().params(),
+ runparams, *save_enc, true, true);
+ os << "\\egroup" << breakln;
runparams.encoding = save_enc;
}