From: Georg Baum Date: Sun, 12 Dec 2010 13:23:05 +0000 (+0000) Subject: Do not use math commands from unicodesymbols in tex2lyx text mode, X-Git-Tag: 2.0.0~1405 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1b04aa730165ba8ea34547866b44365b2b7eb047;p=features.git Do not use math commands from unicodesymbols in tex2lyx text mode, 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 --- diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index f7d16d2b29..ffaa36012f 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -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, diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 72426f550f..1fb49af13d 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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()