Dear Richard, On 2017-05-31, Richard Heck wrote: > On 04/26/2017 03:49 PM, Guenter Milde wrote: >> Dear LyX developers,
>> How important is backwards compatibility for documents generated with LyX >> 2.1 or older? >> a) no need to restore after it's broken by 2.2. >> b) good but not required >> c) small changes tolerable as long as documents >> open and compile >> d) 100% backwards compatibility whenever possible. > I believe the rule is (d). >> Unfortunately, LyX 2.2 breaks backwards compatibility regarding the >> line-break behaviour of em-dash and en-dash (changed behaviour for >> documents using "ligature dashes"). >> Full backwards compatibility with pre-2.2 documents requires separate >> representations for "ligature dashes" and "literal dashes". As 2.2 has >> only "literal dashes", we would need a representation for >> "ligature-dashes" in documents generated with LyX 2.1 or older. >> Which of the alternatives do you prefer in case we want to restore >> compatibility? >> a) -- and --- as ERT > This seems the simplest. Below is a "stub patch", that tries to achieve this but fails due to my limite understanding of C++ and LyX code. I copy-pasted from Text.cpp and factory.cpp and did some edits. However, in a test file (2.1 file containing ---), the inserted ERT was empty and the console showed Lexer.cpp (934): Missing 'ert'-tag in InsetERT::string2params. Got -- instead. Line: 0 Also, I would prefer the new-created ERT-insets to be "closed" (less distractive in the GUI). Günter diff --git a/src/Text.cpp b/src/Text.cpp index 4e593ddf23..790d0bf354 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -52,6 +52,7 @@ #include "insets/InsetText.h" #include "insets/InsetBibitem.h" #include "insets/InsetCaption.h" +#include "insets/InsetERT.h" #include "insets/InsetNewline.h" #include "insets/InsetNewpage.h" #include "insets/InsetArgument.h" @@ -516,10 +517,15 @@ void Text::readParToken(Paragraph & par, Lexer & lex, else par.insert(par.size(), from_ascii("---"), font, change); } else { + auto_ptr<Inset> inset; if (token == "\\twohyphens") - par.insertChar(par.size(), 0x2013, font, change); + inset.reset(new InsetERT(buf, + InsetERT::string2params(to_utf8(_("--"))))); else - par.insertChar(par.size(), 0x2014, font, change); + inset.reset(new InsetERT(buf, + InsetERT::string2params(to_utf8(_("--"))))); + /* inset->setBuffer(*buf); */ + par.insertInset(par.size(), inset.release(), font, change); } } else if (token == "\\backslash") { par.appendChar('\\', font, change);