]> git.lyx.org Git - features.git/commitdiff
tex2lyx: support for TIPA \tone
authorUwe Stöhr <uwestoehr@lyx.org>
Mon, 18 Feb 2013 03:50:18 +0000 (04:50 +0100)
committerUwe Stöhr <uwestoehr@lyx.org>
Mon, 18 Feb 2013 03:50:18 +0000 (04:50 +0100)
- also simplify the code a bit
- test-insets.tex: add missing preamble code

src/tex2lyx/Preamble.cpp
src/tex2lyx/TODO.txt
src/tex2lyx/test/test-insets.lyx.lyx
src/tex2lyx/test/test-insets.tex
src/tex2lyx/text.cpp

index 4b4bb73217efbfbd0f797d19ff0fc52a169f04dd..56be6a180862e6b3a81fdb7598a687d65bced89a 100644 (file)
@@ -182,8 +182,8 @@ const char * const known_lyx_packages[] = {"amsbsy", "amsmath", "amssymb",
 "amstext", "amsthm", "array", "babel", "booktabs", "calc", "CJK", "color",
 "float", "fontspec", "graphicx", "hhline", "ifthen", "longtable", "makeidx",
 "multirow", "nomencl", "pdfpages", "refstyle", "rotating", "rotfloat", "splitidx",
-"setspace", "subscript", "textcomp", "tipa", "tipx", "ulem", "url", "varioref",
-"verbatim", "wrapfig", "xunicode", 0};
+"setspace", "subscript", "textcomp", "tipa", "tipx", "tone", "ulem", "url",
+"varioref", "verbatim", "wrapfig", "xunicode", 0};
 
 // used for the handling of \newindex
 int index_number = 0;
index 42a37085c16d4da6a4b823dda30ea089b9ddc367..8754a29aa1c14d76072fffd03e5764eacbd613c0 100644 (file)
@@ -51,8 +51,7 @@ Format LaTeX feature                        LyX feature
 407    vertical offset for multirows        InsetTabular
 411    support for polyglossia              \language_package  (the cases of no package, of babel and of custom package is supported)
 415    automatic undertilde loading         \use_package undertilde
-438    \tone{51} etc.,                      InsetTIPA
-       \=*{a}, \*r and \*w, \!o
+438    \=*{a}, \*r and \*w, \!o             InsetTIPA
        and \!b and \!d and \!g and \!G,
        \textvertline, \t*{ },
        \textdoublevertline, \textglobfall
index 1013460bd70ba3bff2b5b2dbdd59afcb787c16f0..b4e67c0fd8bc033e45da85d5f6a2a1a701620317 100644 (file)
@@ -6176,326 +6176,11 @@ status collapsed
 \begin_inset IPA
 
 \begin_layout Standard
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-55
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-44
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-33
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-22
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-11
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-ꜜꜛ
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-15
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-51
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-45
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-12
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-
-\backslash
-tone
-\end_layout
-
-\end_inset
-
-
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-{
-\end_layout
-
-\end_inset
-
-454
-\begin_inset ERT
-status collapsed
-
-\begin_layout Plain Layout
-}
-\end_layout
-
-\end_inset
-
+˥˦˧˨˩ꜜꜛ\IPAChar \tone{15}
+\IPAChar \tone{51}
+\IPAChar \tone{45}
+\IPAChar \tone{12}
+\IPAChar \tone{454}
 ↗
 \begin_inset ERT
 status collapsed
index d84657273ccb449e86d31521bfef2bda7cb85a06..09e6dc4ae4ef6def6c509e9d9a8768cbc1d9ee71 100644 (file)
@@ -40,6 +40,9 @@
 \usepackage{amssymb}
 \usepackage{color}
 \usepackage[ps,mover]{lyxskak}
+\usepackage{tipa}
+\usepackage{tipx}
+\usepackage{tone}
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
 \providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
index 474fcb18e6b8a3cd4462db86467dc7718bda0d42..df06be1b2fc747d95fb00c732367eaef7effc77e 100644 (file)
@@ -285,6 +285,17 @@ char const * const known_phrases[] = {"LyX", "TeX", "LaTeXe", "LaTeX", 0};
 char const * const known_coded_phrases[] = {"LyX", "TeX", "LaTeX2e", "LaTeX", 0};
 int const known_phrase_lengths[] = {3, 5, 7, 0};
 
+/// known TIPA combining diacritical marks
+char const * const known_tipa_marks[] = {"textsubwedge", "textsubumlaut",
+"textsubtilde", "textseagull", "textsubbridge", "textinvsubbridge",
+"textsubsquare", "textsubrhalfring", "textsublhalfring", "textsubplus",
+"textovercross", "textsubarch", "textsuperimposetilde", "textraising",
+"textlowering", "textadvancing", "textretracting", "textdoublegrave",
+"texthighrise", "textlowrise", "textrisefall", "textsyllabic", 0};
+
+/// tones that need special handling
+char const * const known_tones[] = {"15", "51", "45", "12", "454", 0};
+
 // string to store the float type to be able to determine the type of subfloats
 string float_type = "";
 
@@ -3238,25 +3249,13 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                }
 
                // the TIPA Combining diacritical marks
-               else if (t.cs() == "textsubwedge" || t.cs() == "textsubumlaut"
-                       || t.cs() == "textsubtilde" || t.cs() == "textseagull"
-                       || t.cs() == "textsubbridge" || t.cs() == "textinvsubbridge"
-                       || t.cs() == "textsubsquare" || t.cs() == "textsubrhalfring"
-                       || t.cs() == "textsublhalfring" || t.cs() == "textsubplus"
-                       || t.cs() == "textovercross" || t.cs() == "textsubarch"
-                       || t.cs() == "textsuperimposetilde" || t.cs() == "textraising"
-                       || t.cs() == "textlowering" || t.cs() == "textadvancing"
-                       || t.cs() == "textretracting" || t.cs() == "textdoublegrave"
-                       || t.cs() == "texthighrise" || t.cs() == "textlowrise"
-                       || t.cs() == "textrisefall" || t.cs() == "textsyllabic") {
+               else if (is_known(t.cs(), known_tipa_marks)) {
                        context.check_layout(os);
                        // try to see whether the string is in unicodesymbols
                        bool termination;
                        docstring rem;
                        string content = trimSpaceAndEol(p.verbatim_item());
-                       string command = t.asInput() + "{"
-                               + trimSpaceAndEol(content)
-                               + "}";
+                       string command = t.asInput() + "{" + content + "}";
                        set<string> req;
                        docstring s = encodings.fromLaTeXCommand(from_utf8(command),
                                Encodings::TEXT_CMD | Encodings::MATH_CMD,
@@ -3267,6 +3266,38 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                                             << ", result is " << to_utf8(s)
                                             << "+" << to_utf8(rem) << endl;
                                os << content << to_utf8(s);
+                               // tipa is already registered because of the surrounding IPA environment
+                               // or \textipa but it does not harm to register it again if necessary
+                               for (set<string>::const_iterator it = req.begin(); it != req.end(); ++it)
+                                       preamble.registerAutomaticallyLoadedPackage(*it);
+                       } else
+                               // we did not find a non-ert version
+                               output_ert_inset(os, command, context);
+               }
+
+               else if (t.cs() == "tone" ) {
+                       context.check_layout(os);
+                       // try to see whether the string is in unicodesymbols
+                       string content = trimSpaceAndEol(p.verbatim_item());
+                       string command = t.asInput() + "{" + content + "}";
+                       // some tones can be detected by unicodesymbols, some need special code
+                       if (is_known(content, known_tones)) {
+                               os << "\\IPAChar " << command << "\n";
+                               continue;
+                       }
+                       bool termination;
+                       docstring rem;
+                       set<string> req;
+                       docstring s = encodings.fromLaTeXCommand(from_utf8(command),
+                               Encodings::TEXT_CMD | Encodings::MATH_CMD,
+                               termination, rem, &req);
+                       if (!s.empty()) {
+                               if (!rem.empty())
+                                       cerr << "When parsing " << command
+                                            << ", result is " << to_utf8(s)
+                                                << "+" << to_utf8(rem) << endl;
+                               os << to_utf8(s);
+                               // thiw will register the package "tone"
                                for (set<string>::const_iterator it = req.begin(); it != req.end(); ++it)
                                        preamble.registerAutomaticallyLoadedPackage(*it);
                        } else