]> git.lyx.org Git - features.git/commitdiff
tex2lyx: support further characters
authorUwe Stöhr <uwestoehr@lyx.org>
Fri, 22 Feb 2013 00:11:30 +0000 (01:11 +0100)
committerUwe Stöhr <uwestoehr@lyx.org>
Fri, 22 Feb 2013 00:11:30 +0000 (01:11 +0100)
- support for Cyrillic characters
- support for \textifsymbol and \ascii (fixes bug #8556)
- support for \ding
- tex2lyx/text.cpp: correct an indentation and use "name2" because "name" is already defined in this clause

src/tex2lyx/test/box-color-size-space-align.lyx.lyx
src/tex2lyx/test/box-color-size-space-align.tex
src/tex2lyx/text.cpp

index 1217a702d0c93f598eb34c6a1f179e0fb7a43732..b578bf7e3ddef7451fc598ff5c941f91292310ca 100644 (file)
@@ -2107,5 +2107,72 @@ smallskip 2:
 
 \end_layout
 
+\begin_layout Section
+Characters
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from package "ascii" and "ifsym": ®↨◻◼ ◙ ◙
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from textcomp: №™
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from textgreek and textcyr: 
+\lang greek
+>a
+\lang english
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from subscript: 
+\begin_inset script subscript
+
+\begin_layout Standard
+
+\size normal
+4
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from tfrupee ₹
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from marvosym and wasysym: ☑☚
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from bbding and pifont: ☆❾
+\end_layout
+
+\begin_layout Standard
+
+\size normal
+from tipa and tipx: ȶȸ
+\end_layout
+
 \end_body
 \end_document
index b3a6d006c7125f4576da05d5652ef58538a7c469..e0428fdf7937aa21c5adc7cd088c701863d4e76d 100644 (file)
 \usepackage{fancybox}
 \PassOptionsToPackage{normalem}{ulem}
 \usepackage{ulem}
+\usepackage{ifsym}
+\usepackage{ascii}
+\usepackage{textgreek}
+\usepackage{textcyr}
+\usepackage{subscript}
+\usepackage{tfrupee}
+\usepackage{bbding}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{pifont}
+\usepackage{tipa}
+\usepackage{tipx}
 
 \setlength{\parskip}{3mm}
 \setlength{\parindent}{0sp}
@@ -427,4 +439,33 @@ smallskip 1:\smallskip
 smallskip 2:\vspace{\smallskipamount}
 
 
+\section{Characters}
+
+from package "ascii" and "ifsym": 
+\textregistered{\ascii\ETB}\textifsymbol[ifgeo]{48}\textifsymbol[ifgeo]{96}
+{\ascii\LF}
+\ascii\LF{}
+
+from textcomp: 
+\textnumero\texttrademark
+
+from textgreek and textcyr:
+\textgreek{>a}\textcyr{\char226}
+
+from subscript:
+\textsubscript{4}
+
+from tfrupee
+\rupee
+
+from marvosym and wasysym:
+\CheckedBox \HandCuffLeft
+
+from bbding and pifont:
+\FiveStarOpen \ding{190}
+
+from tipa and tipx:
+\textctt \textdblig
+
+
 \end{document}
index 46cc347db75d8429a47028fedad1ed4e22da659a..b8a11d41e96ecf1a21233ebf7977f2a204ddf11c 100644 (file)
@@ -2413,15 +2413,15 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        Token const next = p.next_token();
                        Token const end = p.next_next_token();
                        if (next.cat() == catEnd) {
-                       // {}
-                       Token const prev = p.prev_token();
-                       p.get_token();
-                       if (p.next_token().character() == '`' ||
-                           (prev.character() == '-' &&
-                            p.next_token().character() == '-'))
-                               ; // ignore it in {}`` or -{}-
-                       else
-                               output_ert_inset(os, "{}", context);
+                               // {}
+                               Token const prev = p.prev_token();
+                               p.get_token();
+                               if (p.next_token().character() == '`' ||
+                                       (prev.character() == '-' &&
+                                       p.next_token().character() == '-'))
+                                       ; // ignore it in {}`` or -{}-
+                               else
+                                       output_ert_inset(os, "{}", context);
                        } else if (next.cat() == catEscape &&
                                   is_known(next.cs(), known_quotes) &&
                                   end.cat() == catEnd) {
@@ -2431,6 +2431,27 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                // braces here for better readability.
                                parse_text_snippet(p, os, FLAG_BRACE_LAST,
                                                   outer, context);
+                       } else if (p.next_token().asInput() == "\\ascii") {
+                               // handle the \ascii characters
+                               // (the case without braces is handled later)
+                               // the code is "{\ascii\xxx}"
+                               p.get_token(); // eat \ascii
+                               string name2 = p.get_token().asInput();
+                               p.get_token(); // eat the final '}'
+                               string const name = "{\\ascii" + name2 + "}";
+                               bool termination;
+                               docstring rem;
+                               set<string> req;
+                               // get the character from unicodesymbols
+                               docstring s = encodings.fromLaTeXCommand(from_utf8(name),
+                                       Encodings::TEXT_CMD, termination, rem, &req);
+                               if (!s.empty()) {
+                                       context.check_layout(os);
+                                       os << to_utf8(s);
+                               } else
+                                       // we did not find a non-ert version
+                                       output_ert_inset(os, name, context);
+                               continue;
                        } else {
                        context.check_layout(os);
                        // special handling of font attribute changes
@@ -4612,6 +4633,23 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        docstring rem;
                        set<string> req;
                        string name = t.asInput();
+                       // handle the dingbats and Cyrillic
+                       if (name == "\\ding" || name == "\\textcyr")
+                               name = name + '{' + p.getArg('{', '}') + '}';
+                       // handle the ifsym characters
+                       if (name == "\\textifsymbol") {
+                               string const optif = p.getFullOpt();
+                               string const argif = p.getArg('{', '}');
+                               name = name + optif + '{' + argif + '}';
+                       }
+                       // handle the \ascii characters
+                       // the case of \ascii within braces, as LyX outputs it, is already
+                       // handled for t.cat() == catBegin
+                       if (name == "\\ascii") {
+                               // the code is "\asci\xxx"
+                               name = "{" + name + p.get_token().asInput() + "}";
+                               skip_braces(p);
+                       }
                        // handle some TIPA special characters
                        if (name == "\\textglobfall") {
                                name = "End";
@@ -4704,14 +4742,14 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        output_ert_inset(os, s + ' ', context);
                        */
                        else {
-                               string name = t.asInput();
+                               string name2 = t.asInput();
                                if (p.next_token().asInput() == "*") {
                                        // Starred commands like \vspace*{}
                                        p.get_token();  // Eat '*'
-                                       name += '*';
+                                       name2 += '*';
                                }
-                               if (!parse_command(name, p, os, outer, context))
-                                       output_ert_inset(os, name, context);
+                               if (!parse_command(name2, p, os, outer, context))
+                                       output_ert_inset(os, name2, context);
                        }
                }