]> git.lyx.org Git - features.git/commitdiff
Add "Plain" quotation mark style
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 21 Dec 2016 14:17:30 +0000 (15:17 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 21 Dec 2016 14:17:30 +0000 (15:17 +0100)
File format change

13 files changed:
development/FORMAT
lib/languages
lib/lyx2lyx/lyx_2_3.py
lib/ui/stdmenus.inc
src/BufferParams.cpp
src/LaTeXFeatures.cpp
src/LyXAction.cpp
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/Menus.cpp
src/insets/InsetQuotes.cpp
src/insets/InsetQuotes.h
src/tex2lyx/TODO.txt
src/version.h

index 999ff2a902ba0e431494ac0dd8f5c87e9d32ace5..9cc37edd848b613001de7bf191a8718a60fc33b0 100644 (file)
@@ -11,6 +11,13 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
 
 -----------------------
 
+2016-12-21 Jürgen Spitzmüller <spitz@lyx.org>
+       * Format incremented to 520: Introduce plain quote style:
+          \begin_inset Quotes qls => \textquotesingle
+          \begin_inset Quotes qld => \textquotesingle
+          \begin_inset Quotes qrs => \textquotedbl
+          \begin_inset Quotes qrd => \textquotedbl
+
 2016-12-20 Jürgen Spitzmüller <spitz@lyx.org>
        * Format incremented to 519: rename \quotes_language to \quotes_style.
 
index 9175812050f2af0337210596ef0090309bb4fe5e..2df8f0a82480a45e02b8778c1fc2160bc9ff84e4 100644 (file)
@@ -49,6 +49,7 @@
 #   - german:  ,,text``  ,text`   (99/66)
 #   - polish:  ,,text''  ,text'   (99/99)
 #   - swedish: ''text''  'text'   (99_99)
+#   - plain:   "text"    'text'    (straight non-typographical quotes)
 #   Note that the option names have been selected (rather arbitrarily)
 #   because the respective styles are common in the respective countries.
 #   Of course this does not imply any fixed relation to those countries.
index 35975bce8e8637165ae7822b6b6bf7b4644e2127..69493641409f86db778635de3c1f487661b49d24 100644 (file)
@@ -666,6 +666,33 @@ def revert_quotestyle(document):
     document.header[i] = "\\quotes_language " + val
 
 
+def revert_plainquote(document):
+    " Revert plain quote inset "
+
+    # First, revert style setting
+    i = find_token(document.header, "\\quotes_style plain", 0)
+    if i != -1:
+        document.header[i] = "\\quotes_style english"
+
+    # now the insets
+    i = 0
+    j = 0
+    while True:
+        k = find_token(document.body, '\\begin_inset Quotes q', i)
+        if k == -1:
+            return
+        l = find_end_of_inset(document.body, k)
+        if l == -1:
+            document.warning("Malformed LyX document: Can't find end of Quote inset at line " + str(k))
+            i = k
+            continue
+        replace = "\""
+        if document.body[k].endswith("s"):
+            replace = "'"
+        document.body[k:l+1] = [replace]
+        i = l
+
+
 ##
 # Conversion hub
 #
@@ -682,10 +709,12 @@ convert = [
            [516, [convert_inputenc]],
            [517, []],
            [518, [convert_iopart]],
-           [519, [convert_quotestyle]]
+           [519, [convert_quotestyle]],
+           [520, []]
           ]
 
 revert =  [
+           [519, [revert_plainquote]],
            [518, [revert_quotestyle]],
            [517, [revert_iopart]],
            [516, [revert_quotes]],
index 3404fa8afc3eb43c9843bb0c1831467701da36ff..47e7b61e81272e2d4485a5bb52f62e508df6393a 100644 (file)
@@ -400,8 +400,8 @@ Menuset
                Item "Symbols...|b" "dialog-show symbols"
                Item "Ellipsis|i" "specialchar-insert dots"
                Item "End of Sentence|E" "specialchar-insert end-of-sentence"
-               Item "Ordinary Quote|Q" "self-insert \""
-               Item "Single Quote|S" "quote-insert single"
+               Item "Plain Quotation Mark|Q" "quote-insert double auto plain"
+               Item "Single Quotation Mark|S" "quote-insert single"
                Item "Protected Hyphen|y" "specialchar-insert nobreakdash"
                Item "Breakable Slash|a" "specialchar-insert slash"
                Item "Visible Space|V" "space-insert visible"
index 487f0341b37a88b1f539f033dffe3cc1e3dd1232..00cbbedfe87b74054410b2d141cc0f22e25f2ae0 100644 (file)
@@ -72,7 +72,7 @@ static char const * const string_paragraph_separation[] = {
 
 
 static char const * const string_quotes_style[] = {
-       "english", "swedish", "german", "polish", "french", "danish", ""
+       "english", "swedish", "german", "polish", "french", "danish", "plain", ""
 };
 
 
@@ -140,6 +140,7 @@ QuotesStyleTranslator const init_quotesstyletranslator()
        translator.addPair(string_quotes_style[3], InsetQuotes::PolishQuotes);
        translator.addPair(string_quotes_style[4], InsetQuotes::FrenchQuotes);
        translator.addPair(string_quotes_style[5], InsetQuotes::DanishQuotes);
+       translator.addPair(string_quotes_style[6], InsetQuotes::PlainQuotes);
        return translator;
 }
 
index 777924c5a2b454576ec3b712becd33c76564a541..4c993b6f7b9c55041a4a08e1e9b2f0490b5725d2 100644 (file)
@@ -118,6 +118,25 @@ static docstring const guilsinglright_def = from_ascii(
        "  {\\usefont{U}{lasy}{m}{n}\\char'51}%\n"
        "}");
 
+static docstring const textquotedbl_def = from_ascii(
+       "\\DeclareTextSymbolDefault{\\textquotedbl}{T1}");
+
+static docstring const textquotedblp_xetex_def = from_ascii(
+       "\\providecommand\\textquotedblplain{%\n"
+       "  \\bgroup\\addfontfeatures{Mapping=}\\textquotedbl\\egroup}");
+
+static docstring const textquotedblp_luatex_def = from_ascii(
+       "\\providecommand\\textquotedblplain{%\n"
+       "  \\bgroup\\addfontfeatures{RawFeature=-tlig}\\textquotedbl\\egroup}");
+
+static docstring const textquotesinglep_xetex_def = from_ascii(
+       "\\providecommand\\textquotesingleplain{%\n"
+       "  \\bgroup\\addfontfeatures{Mapping=}\\textquotesingle\\egroup}");
+
+static docstring const textquotesinglep_luatex_def = from_ascii(
+       "\\providecommand\\textquotesingleplain{%\n"
+       "  \\bgroup\\addfontfeatures{RawFeature=-tlig}\\textquotesingle\\egroup}");
+
 static docstring const paragraphleftindent_def = from_ascii(
        "\\newenvironment{LyXParagraphLeftIndent}[1]%\n"
        "{\n"
@@ -1373,6 +1392,20 @@ TexString LaTeXFeatures::getMacros() const
                macros << guillemotleft_def << '\n';
        if (mustProvide("guillemotright"))
                macros << guillemotright_def << '\n';
+       if (mustProvide("textquotedbl"))
+               macros << textquotedbl_def << '\n';
+       if (mustProvide("textquotesinglep")) {
+               if (runparams_.flavor == OutputParams::XETEX)
+                       macros << textquotesinglep_xetex_def << '\n';
+               else
+                       macros << textquotesinglep_luatex_def << '\n';
+       }
+       if (mustProvide("textquotedblp")) {
+               if (runparams_.flavor == OutputParams::XETEX)
+                       macros << textquotedblp_xetex_def << '\n';
+               else
+                       macros << textquotedblp_luatex_def << '\n';
+       }
 
        // Math mode
        if (mustProvide("binom") && !isRequired("amsmath"))
index 9b8ae1650441a6b6adb24303ade2f452a1ec056a..63b4a69beee77b1c91d43f961456cf88076e810a 100644 (file)
@@ -414,6 +414,7 @@ void LyXAction::init()
  *                      'polish' for ,,Polish'' quote style
  *                      'french' for <<French>> quote style
  *                      'danish' for >>Danish<< quote style
+ *                      'plain' for "Plain" quote style
  *                      If no quote style is specified, the document-wide will be used.
  * \endvar
  */
index 97d4d205eb138b2b291dc8a57d5da52dc5781ff2..33abb3abcc5f04218d005b015dc3e2a3f620d343 100644 (file)
@@ -1079,6 +1079,8 @@ GuiDocument::GuiDocument(GuiView & lv)
                qt_("<<text>>"), InsetQuotes::FrenchQuotes);
        langModule->quoteStyleCO->addItem(
                qt_(">>text<<"), InsetQuotes::DanishQuotes);
+       langModule->quoteStyleCO->addItem(
+               qt_("\"text\""), InsetQuotes::PlainQuotes);
 
        langModule->languagePackageCO->addItem(
                qt_("Default"), toqstr("default"));
index 5a7e8e09aa182df39b7cd8705572de66d3e34165..25467dbf8f0d1dd364aaf4b1d45735e3750e6a93 100644 (file)
@@ -1681,6 +1681,7 @@ void MenuDefinition::expandQuotes(BufferView const * bv)
        MenuDefinition pqs;
        MenuDefinition fqs;
        MenuDefinition aqs;
+       MenuDefinition qqs;
        for (; qq != end; ++qq) {
                docstring const style = from_ascii(qq->first);
                FuncRequest const cmd = FuncRequest(LFUN_INSET_MODIFY, from_ascii("changetype ") + style);
@@ -1700,6 +1701,8 @@ void MenuDefinition::expandQuotes(BufferView const * bv)
                        fqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
                else if (prefixIs(style, 'a') && !prefixIs(qtype, "a"))
                        aqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
+               else if (prefixIs(style, 'q') && !prefixIs(qtype, "q"))
+                       qqs.add(MenuItem(MenuItem::Command, toqstr(desc), cmd));
        }
 
        if (!eqs.empty()) {
@@ -1732,6 +1735,11 @@ void MenuDefinition::expandQuotes(BufferView const * bv)
                item.setSubmenu(aqs);
                add(item);
        }
+       if (!qqs.empty()) {
+               MenuItem item(MenuItem::Submenu, qt_("\"text\""));
+               item.setSubmenu(qqs);
+               add(item);
+       }
 }
 
 
index 768c6c72127364fb3a28acbba00ce4a70fb82561..cc3e3e051e1475b62f558d4727e63c177e97e665 100644 (file)
@@ -53,57 +53,58 @@ namespace {
  * p    ,,polish''
  * f    <<french>>
  * a    >>danish<<
+ * q    "plain"
  */
 
-char const * const style_char = "esgpfa";
+char const * const style_char = "esgpfaq";
 char const * const side_char = "lr" ;
 char const * const level_char = "sd";
 
 // List of known quote chars
-char const * const quote_char = ",'`<>";
+char const * const quote_char = ",'`<>\"";
 
 // Unicode characters needed by each quote type
-char_type const display_quote_char[2][5] = {
-       { 0x201a, 0x2019, 0x2018, 0x2039, 0x203a},
-       { 0x201e, 0x201d, 0x201c, 0x00ab, 0x00bb}
+char_type const display_quote_char[2][6] = {
+       { 0x201a, 0x2019, 0x2018, 0x2039, 0x203a, 0x0027},
+       { 0x201e, 0x201d, 0x201c, 0x00ab, 0x00bb, 0x0022}
 };
 
 // Index of chars used for the quote. Index is [side, style]
-int quote_index[2][6] = {
-       { 2, 1, 0, 0, 3, 4 },    // "'',,<>"
-       { 1, 1, 2, 1, 4, 3 }     // "`'`'><"
+int quote_index[2][7] = {
+       { 2, 1, 0, 0, 3, 4, 5 },  // { ` ' , , < > \" }
+       { 1, 1, 2, 1, 4, 3, 5 }   // { ' ' ` ' > < \" }
 };
 
 // Corresponding LaTeX code, for double and single quotes.
-char const * const latex_quote_t1[2][5] = {
+char const * const latex_quote_t1[2][6] = {
        { "\\quotesinglbase",  "'", "`",
-    "\\guilsinglleft", "\\guilsinglright" },
-  { ",,", "''", "``", "<<", ">>" }
+    "\\guilsinglleft", "\\guilsinglright", "\\textquotesingle" },
+  { ",,", "''", "``", "<<", ">>", "\\textquotedbl" }
 };
 
-char const * const latex_quote_ot1[2][5] = {
+char const * const latex_quote_ot1[2][6] = {
        { "\\quotesinglbase",  "'", "`",
-    "\\guilsinglleft", "\\guilsinglright" },
+    "\\guilsinglleft", "\\guilsinglright", "\\textquotesingle" },
   { "\\quotedblbase", "''", "``",
-    "\\guillemotleft", "\\guillemotright" }
+    "\\guillemotleft", "\\guillemotright", "\\textquotedbl" }
 };
 
-char const * const latex_quote_noligatures[2][5] = {
+char const * const latex_quote_noligatures[2][6] = {
        { "\\quotesinglbase",  "\\textquoteleft", "\\textquoteright",
-    "\\guilsinglleft", "\\guilsinglright" },
+    "\\guilsinglleft", "\\guilsinglright", "\\textquotesingle" },
   { "\\quotedblbase", "\\textquotedblleft", "\\textquotedblright",
-    "\\guillemotleft", "\\guillemotright" }
+    "\\guillemotleft", "\\guillemotright", "\\textquotedbl" }
 };
 
-char const * const latex_quote_babel[2][5] = {
-       { "\\glq",  "'", "`", "\\flq", "\\frq" },
-  { "\\glqq", "''", "``", "\\flqq", "\\frqq" }
+char const * const latex_quote_babel[2][6] = {
+       { "\\glq",  "'", "`", "\\flq", "\\frq", "\\textquotesingle" },
+  { "\\glqq", "''", "``", "\\flqq", "\\frqq", "\\textquotedbl" }
 };
 
-char const * const html_quote[2][5] = {
+char const * const html_quote[2][6] = {
        { "&sbquo;",  "&rsquo;", "&lsquo;",
-         "&lsaquo;", "&rsaquo;" },
-  { "&bdquo;", "&rdquo;", "&ldquo;", "&laquo;", "&raquo;" }
+         "&lsaquo;", "&rsaquo;", "&#x27;" },
+  { "&bdquo;", "&rdquo;", "&ldquo;", "&laquo;", "&raquo;", "&quot;" }
 };
 
 } // namespace anon
@@ -171,13 +172,13 @@ void InsetQuotes::parseString(string const & s, bool const allow_wildcards)
 
        // '.' wildcard means: keep current stylee
        if (!allow_wildcards || str[0] != '.') {
-               for (i = 0; i < 6; ++i) {
+               for (i = 0; i < 7; ++i) {
                        if (str[0] == style_char[i]) {
                                style_ = QuoteStyle(i);
                                break;
                        }
                }
-               if (i >= 6) {
+               if (i >= 7) {
                        lyxerr << "ERROR (InsetQuotes::InsetQuotes):"
                                " bad style specification." << endl;
                        style_ = EnglishQuotes;
@@ -232,6 +233,8 @@ InsetQuotes::QuoteStyle InsetQuotes::getStyle(string const & s)
                qs = FrenchQuotes;
        else if (s == "danish")
                qs = DanishQuotes;
+       else if (s == "plain")
+               qs = PlainQuotes;
 
        return qs;
 }
@@ -248,7 +251,7 @@ map<string, docstring> InsetQuotes::getTypes() const
        string type;
 
        // get all quote types
-       for (sty = 0; sty < 6; ++sty) {
+       for (sty = 0; sty < 7; ++sty) {
                style = QuoteStyle(sty);
                for (sid = 0; sid < 2; ++sid) {
                        side = QuoteSide(sid);
@@ -276,7 +279,6 @@ docstring InsetQuotes::displayString() const
        docstring retdisp = docstring(1, display_quote_char[level_][index]);
 
        // in French, thin spaces are added inside double guillemets
-       // FIXME: this should be done by a separate quote type.
        if (prefixIs(context_lang_, "fr")
            && level_ == DoubleQuotes && style_ == FrenchQuotes) {
                // THIN SPACE (U+2009)
@@ -388,6 +390,12 @@ void InsetQuotes::latex(otexstream & os, OutputParams const & runparams) const
        // In pass-thru context, we output plain quotes
        if (runparams.pass_thru)
                qstr = (level_ == DoubleQuotes) ? from_ascii("\"") : from_ascii("'");
+       else if (style_ == PlainQuotes && runparams.isFullUnicode()) {
+               // For XeTeX and LuaTeX,we need to disable mapping to get straight
+               // quotes. We define our own commands that do this
+               qstr = (level_ == DoubleQuotes) ?
+                       from_ascii("\\textquotedblplain") : from_ascii("\\textquotesingleplain");
+       }
        else if (runparams.use_polyglossia) {
                // For polyglossia, we directly output the respective unicode chars 
                // (spacing and kerning is then handled respectively)
@@ -459,7 +467,6 @@ docstring InsetQuotes::getQuoteEntity() const {
        const int quoteind = quote_index[side_][style_];
        docstring res = from_ascii(html_quote[level_][quoteind]);
        // in French, thin spaces are added inside double guillemets
-       // FIXME: this should be done by a separate quote type.
        if (prefixIs(context_lang_, "fr")
            && level_ == DoubleQuotes && style_ == FrenchQuotes) {
                // THIN SPACE (U+2009)
@@ -517,22 +524,56 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
 #else
        if (!features.useBabel()
 #endif
-           && !features.usePolyglossia() && fontenc_ != "T1") {
+           && !features.runparams().isFullUnicode() && fontenc_ != "T1") {
                if (level_ == SingleQuotes)
                        switch (type) {
-                       case ',': features.require("quotesinglbase"); break;
-                       case '<': features.require("guilsinglleft");  break;
-                       case '>': features.require("guilsinglright"); break;
-                       default: break;
+                       case ',':
+                               features.require("quotesinglbase");
+                               break;
+                       case '<':
+                               features.require("guilsinglleft");
+                               break;
+                       case '>':
+                               features.require("guilsinglright");
+                               break;
+                       default:
+                               break;
                        }
                else
                        switch (type) {
-                       case ',': features.require("quotedblbase");   break;
-                       case '<': features.require("guillemotleft");  break;
-                       case '>': features.require("guillemotright"); break;
-                       default: break;
+                       case ',':
+                               features.require("quotedblbase");
+                               break;
+                       case '<':
+                               features.require("guillemotleft");
+                               break;
+                       case '>':
+                               features.require("guillemotright");
+                               break;
+                       default:
+                               break;
                        }
        }
+       if (type == '"') {
+               switch (level_) {
+               case SingleQuotes: {
+                       if (features.runparams().isFullUnicode())
+                               features.require("textquotesinglep");
+                       else
+                               features.require("textcomp");
+                       break;
+               }
+               case DoubleQuotes: {
+                       if (features.runparams().isFullUnicode())
+                               features.require("textquotedblp");
+                       else if (fontenc_ != "T1")
+                               features.require("textquotedbl");
+                       break;
+               default:
+                       break;
+               }
+               }
+       }
 }
 
 
index 0d50c1299c25f766507cc7a53902ad5a0999bbc9..57f3fef1c2e1e229ab552d136a64b3b925b4bc61 100644 (file)
@@ -38,7 +38,9 @@ public:
                ///
                FrenchQuotes,
                ///
-               DanishQuotes
+               DanishQuotes,
+               ///
+               PlainQuotes
        };
        ///
        enum QuoteSide {
index 233950bf0cc2fb5b1f3215550db8ab2d4cf577bb..46353e822531a10e9e4cd4e0981086e6d38e2a28 100644 (file)
@@ -83,6 +83,9 @@ Format LaTeX feature                        LyX feature
        \twocolumn[]{}{}                      Layout Twocolumn, InsetArgument
        \item[]<>                             InsetArgument
        \begin{enumerate|itemize|...}[]       InsetArgument
+520    Plain InsetQuote Style:
+       \textquotesingle                      \begin_inset Quotes qls, \begin_inset Quotes qrs
+       \textquotedbl                         \begin_inset Quotes qld, \begin_inset Quotes qrd
 
 General
 
index fecef7b2ded7679984f81a50305be944da901643..053c203d3da898cbd73dfe1142caad7700c9080a 100644 (file)
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 519 // spitz: \\quotes_language -> \\quotes_style
-#define LYX_FORMAT_TEX2LYX 519
+#define LYX_FORMAT_LYX 520 // spitz: plain quotes style
+#define LYX_FORMAT_TEX2LYX 520
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER