]> git.lyx.org Git - features.git/commitdiff
Do not use math commands from unicodesymbols in tex2lyx text mode,
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 12 Dec 2010 13:23:05 +0000 (13:23 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 12 Dec 2010 13:23:05 +0000 (13:23 +0000)
since they are usually invalid in text mode (partial fix of bug 6797).
Also, prepare proper translation of \\slash{} and \nobreakdash.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36840 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/test/test-insets.tex
src/tex2lyx/text.cpp

index f7d16d2b29b20fedf6603143095b170f16b98617..ffaa36012fa706ffd581cb732b037f0fff625c27 100644 (file)
@@ -147,7 +147,8 @@ or by a defined page break \pagebreak[4]
 \section{Special characters\index{Special characters}}
 
 Then one has those macros with a long name for a short meaning, like
-\textasciitilde, \textasciicircum{} or \textbackslash{}, and the characters
+\textasciitilde, \textasciicircum{} or \textbackslash{}, \slash{},
+\nobreakdash and the characters
 that LaTeX wants to espace because they are active, like \_\&\#\$\{\}\%.
 
 And what about special characters like hyphe\-nation mark,
index 72426f550f166822fee8045af69ec4bdfda4eb0c..1fb49af13dfd825bed575860b64ec235fc3231fc 100644 (file)
@@ -2330,6 +2330,17 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        skip_braces(p);
                }
 
+               else if (LYX_FORMAT >= 307 && t.cs() == "slash") {
+                       context.check_layout(os);
+                       os << "\\SpecialChar \\slash{}\n";
+                       skip_braces(p);
+               }
+
+               else if (LYX_FORMAT >= 307 && t.cs() == "nobreakdash") {
+                       context.check_layout(os);
+                       os << "\\SpecialChar \\nobreakdash\n";
+               }
+
                else if (t.cs() == "textquotedbl") {
                        context.check_layout(os);
                        os << "\"";
@@ -2695,8 +2706,11 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
 
                else {
                        // try to see whether the string is in unicodesymbols
+                       // Only use text mode commands, since we are in text mode here,
+                       // and math commands may be invalid (bug 6797)
                        docstring rem;
-                       docstring s = encodings.fromLaTeXCommand(from_utf8(t.asInput()), rem);
+                       docstring s = encodings.fromLaTeXCommand(from_utf8(t.asInput()),
+                                                                rem, Encodings::TEXT_CMD);
                        if (!s.empty()) {
                                if (!rem.empty())
                                        cerr << "When parsing " << t.cs()