This gets rid of the hardcoded latin1 encoding for verbatim. Instead,
verbatim now inherits the encoding from the context, which is what is
actually wanted here.
Fixes: #9012, #9258
# Pure 7bit ASCII encoding (partially hardcoded in LyX)
Encoding ascii ascii "ASCII" ascii fixed none
End
# Pure 7bit ASCII encoding (partially hardcoded in LyX)
Encoding ascii ascii "ASCII" ascii fixed none
End
+
+# Semantic encodings
+
+# Inherit encoding of the context (used by verbatim)
+Encoding inherit inherit "" "" fixed none
+End
# * Encoding is the default encoding used with TeX fonts.
# It is only used if Document > Settings > Language > Encoding
# is set to "Language Default" and "use non-TeX fonts" is FALSE.
# * Encoding is the default encoding used with TeX fonts.
# It is only used if Document > Settings > Language > Encoding
# is set to "Language Default" and "use non-TeX fonts" is FALSE.
+# Encoding "inherit" means: keep encoding of the context (used by
+# latex_language).
# * InternalEncoding is used to tell LyX that babel internally sets a
# non-standard font encoding (such as hebrew to LHE or greek to LGR).
# If True, LyX cares for characters/macros that do not exist in
# * InternalEncoding is used to tell LyX that babel internally sets a
# non-standard font encoding (such as hebrew to LHE or greek to LGR).
# If True, LyX cares for characters/macros that do not exist in
GuiName "Ignore"
BabelName ignore
PolyglossiaName ignore
GuiName "Ignore"
BabelName ignore
PolyglossiaName ignore
LangCode ignore
End
Language latex
GuiName "LaTeX"
LangCode ignore
End
Language latex
GuiName "LaTeX"
Text const & text = *sl.text();
Font font = text.getPar(sl.pit()).getFont(bp, sl.pos(),
text.outerFont(sl.pit()));
Text const & text = *sl.text();
Font font = text.getPar(sl.pit()).getFont(bp, sl.pos(),
text.outerFont(sl.pit()));
+ Encoding const * enc = font.language()->encoding();
+ if (enc->name() == "inherit") {
+ size_t const n = depth();
+ for (size_t i = 0; i < n; ++i) {
+ Text const & otext = *slices_[i].text();
+ Font ofont = otext.getPar(slices_[i].pit()).getFont(bp, slices_[i].pos(),
+ otext.outerFont(slices_[i].pit()));
+ if (ofont.language()->encoding()->name() != "inherit")
+ return ofont.language()->encoding();
+ }
+ }
return font.language()->encoding();
}
return font.language()->encoding();
}
- // Prevent to insert uncodable characters in verbatim and ERT
- // (workaround for bug 9012)
- // Don't do it for listings inset, since InsetListings::latex() tries
- // to switch to a usable encoding which works in many cases (bug 9102).
- if (par.isPassThru() && cur.inset().lyxCode() != LISTINGS_CODE &&
- cur.current_font.language()) {
- Encoding const * e = cur.current_font.language()->encoding();
+ // Prevent to insert uncodable characters in verbatim and ERT.
+ // The encoding is inherited from the context here.
+ if (par.isPassThru() && cur.getEncoding()) {
+ Encoding const * e = cur.getEncoding();
- cur.message(_("Character is uncodable in verbatim paragraphs."));
+ cur.message(_("Character is uncodable in this verbatim context."));
Encodings::const_iterator it = encodings.begin();
Encodings::const_iterator const end = encodings.end();
for (auto const & encvar : encodings) {
Encodings::const_iterator it = encodings.begin();
Encodings::const_iterator const end = encodings.end();
for (auto const & encvar : encodings) {
+ if (!encvar.unsafe() && !encvar.guiName().empty())
encodinglist.append(qt_(encvar.guiName()));
}
encodinglist.sort();
encodinglist.append(qt_(encvar.guiName()));
}
encodinglist.sort();
// * with useNonTeXFonts: "utf8plain",
// * with XeTeX and TeX fonts: "ascii" (inputenc fails),
// * with LuaTeX and TeX fonts: only one encoding accepted by luainputenc.
// * with useNonTeXFonts: "utf8plain",
// * with XeTeX and TeX fonts: "ascii" (inputenc fails),
// * with LuaTeX and TeX fonts: only one encoding accepted by luainputenc.
- if (runparams.isFullUnicode())
+ if (runparams.isFullUnicode() || newEnc.name() == "inherit")
return make_pair(false, 0);
Encoding const & oldEnc = *runparams.encoding;
return make_pair(false, 0);
Encoding const & oldEnc = *runparams.encoding;