commit 6c4c16453173774d07bdd8f2b626b7f269687f82
Author: Juergen Spitzmueller <[email protected]>
Date: Wed Dec 7 15:37:03 2016 +0100
Fix some quote inset bugs:
* Adjoining closing Single + double quote becomes double + single quote
(for English, Swedish and German, LaTeX export as ''').
* French double quotes are converted to << >> in the LaTeX file and to
double inverted question/interrogation marks in the output, if the font
encoding is set to [None] or OT1 but the global default is T1. (test
for lyxrc.fontenc instead of the document-specific fontenc setting in
InsetQuotes.cpp).
* Quote type ignored for LyXHTML: always "English" quotes used.
See #10451
---
src/insets/InsetQuotes.cpp | 37 ++++++++++++++++++++++---------------
src/insets/InsetQuotes.h | 2 ++
status.22x | 8 ++++++++
3 files changed, 32 insertions(+), 15 deletions(-)
diff --git a/src/insets/InsetQuotes.cpp b/src/insets/InsetQuotes.cpp
index 039465d..26a3d33 100644
--- a/src/insets/InsetQuotes.cpp
+++ b/src/insets/InsetQuotes.cpp
@@ -87,6 +87,12 @@ char const * const latex_quote_babel[2][5] = {
{ "\\glqq ", "''", "``", "\\flqq{}", "\\frqq{}" }
};
+char const * const html_quote[2][5] = {
+ { "‚", "’", "‘",
+ "‹", "›" },
+ { "„", "”", "“", "«", "»" }
+};
+
} // namespace anon
@@ -98,8 +104,15 @@ InsetQuotes::InsetQuotes(Buffer * buf, string const & str)
: Inset(buf)
InsetQuotes::InsetQuotes(Buffer * buf, char_type c, QuoteTimes t)
: Inset(buf), times_(t)
{
- if (buf)
+ if (buf) {
language_ = buf->params().quotes_language;
+ fontenc_ = (buf->params().fontenc == "global")
+ ? lyxrc.fontenc : buf->params().fontenc;
+ } else {
+ language_ = EnglishQuotes;
+ fontenc_ = lyxrc.fontenc;
+ }
+
setSide(c);
}
@@ -264,7 +277,7 @@ void InsetQuotes::latex(otexstream & os, OutputParams const
& runparams) const
qstr = "\\og "; //the spaces are important here
else
qstr = " \\fg{}"; //and here
- } else if (lyxrc.fontenc == "T1" && !runparams.use_polyglossia) {
+ } else if (fontenc_ == "T1" && !runparams.use_polyglossia) {
qstr = latex_quote_t1[times_][quoteind];
#ifdef DO_USE_DEFAULT_LANGUAGE
} else if (doclang == "default") {
@@ -277,12 +290,14 @@ void InsetQuotes::latex(otexstream & os, OutputParams
const & runparams) const
qstr = latex_quote_babel[times_][quoteind];
}
- // Always guard against unfortunate ligatures (!` ?`)
+ // Always guard against unfortunate ligatures (!` ?` `` '' ,, << >>)
+ char_type const lastchar = os.lastChar();
if (prefixIs(qstr, "`")) {
- char_type const lastchar = os.lastChar();
if (lastchar == '!' || lastchar == '?')
qstr.insert(0, "{}");
}
+ if (qstr[1] == lastchar)
+ qstr.insert(0, "{}");
os << from_ascii(qstr);
}
@@ -298,16 +313,8 @@ int InsetQuotes::plaintext(odocstringstream & os,
docstring InsetQuotes::getQuoteEntity() const {
- if (times_ == DoubleQuotes) {
- if (side_ == LeftQuote)
- return from_ascii("“");
- else
- return from_ascii("”");
- }
- if (side_ == LeftQuote)
- return from_ascii("‘");
- else
- return from_ascii("’");
+ const int quoteind = quote_index[side_][language_];
+ return from_ascii(html_quote[times_][quoteind]);
}
@@ -346,7 +353,7 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
#else
if (!features.useBabel()
#endif
- && lyxrc.fontenc != "T1") {
+ && fontenc_ != "T1") {
if (times_ == SingleQuotes)
switch (type) {
case ',': features.require("quotesinglbase"); break;
diff --git a/src/insets/InsetQuotes.h b/src/insets/InsetQuotes.h
index fec7fbc..49bd842 100644
--- a/src/insets/InsetQuotes.h
+++ b/src/insets/InsetQuotes.h
@@ -116,6 +116,8 @@ private:
QuoteSide side_;
///
QuoteTimes times_;
+ ///
+ std::string fontenc_;
};
} // namespace lyx
diff --git a/status.22x b/status.22x
index 1730858..d7cab35 100644
--- a/status.22x
+++ b/status.22x
@@ -100,6 +100,14 @@ What's new
- Correct encoding for Baltic languages like Lithuanian (bug 10474).
+- Fix some quote inset bugs (bug 10451):
+ # Adjoining closing Single + double quote becomes double + single quote
+ (for English, Swedish and German).
+ # French double quotes are converted to << >> in the LaTeX file and to double
+ inverted question/interrogation marks in the output, if the font encoding
is
+ set to [None] or OT1 but the global default is T1.
+ # Quote type ignored for LyXHTML: always "English" quotes used.
+
* LYX2LYX