From b25016b6134e6a582b507d78d9afe727dbcdad3d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Mon, 18 Feb 2013 03:23:34 +0100 Subject: [PATCH] tex2lyx: more support for TIPA - support for the combining diacritical marks - support for \texttoptiebar and \textbottomtiebar - test-insets.lyx: add complete testcase - TODO.txt: update what still needs to be done --- src/tex2lyx/TODO.txt | 8 +- src/tex2lyx/test/test-insets.lyx.lyx | 620 +++++++++++++++++++++++++-- src/tex2lyx/test/test-insets.tex | 67 ++- src/tex2lyx/text.cpp | 47 +- 4 files changed, 702 insertions(+), 40 deletions(-) diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index e223501492..42a37085c1 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -51,9 +51,11 @@ 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}, \tone{15}, \tone{45}, InsetTIPA - \tone{12}, \tone{454}, \toptiebar, - \bottomtiebar +438 \tone{51} etc., InsetTIPA + \=*{a}, \*r and \*w, \!o + and \!b and \!d and \!g and \!G, + \textvertline, \t*{ }, + \textdoublevertline, \textglobfall 439 MinionPro.sty \font_roman, \font_osf 440 MinionPro.sty, \font_math 443 unicode-math.sty InsetMath* diff --git a/src/tex2lyx/test/test-insets.lyx.lyx b/src/tex2lyx/test/test-insets.lyx.lyx index af9c2de849..1013460bd7 100644 --- a/src/tex2lyx/test/test-insets.lyx.lyx +++ b/src/tex2lyx/test/test-insets.lyx.lyx @@ -5699,7 +5699,382 @@ TIPA \begin_inset IPA \begin_layout Standard -[@n IÉ¡"zA:mpl] + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +r{e} +\end_layout + +\end_inset + + e̬ e̤ eË· e̼ e̪ e̺ eÌ» e +\begin_inset script superscript + +\begin_layout Standard +h +\end_layout + +\end_inset + + e̹ e̜ e̟ +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +={*} +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +{ +\end_layout + +\end_inset + +e +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +} +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +b{e} +\end_layout + +\end_inset + + ë e̽ +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +s +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +{ +\end_layout + +\end_inset + +e +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +} +\end_layout + +\end_inset + + eÌ© e̯ e˞e +\begin_inset script superscript + +\begin_layout Standard +w +\end_layout + +\end_inset + + e +\begin_inset script superscript + +\begin_layout Standard +j +\end_layout + +\end_inset + + e +\begin_inset script superscript + +\begin_layout Standard +É£ +\end_layout + +\end_inset + + e +\begin_inset script superscript + +\begin_layout Standard +ʕ +\end_layout + +\end_inset + + eÌ´ e̝ e̞ e̘ e̙ ẽ e +\begin_inset script superscript + +\begin_layout Standard +n +\end_layout + +\end_inset + + e +\begin_inset script superscript + +\begin_layout Standard +l +\end_layout + +\end_inset + + e˺ +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +H{e} +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +è ē é eȅ ě ê e᷄ e᷅ e᷈ ĕ +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset IPA + +\begin_layout Standard +pbtd t dcɟkÉ¡q G +\end_layout + +\end_inset + + +\begin_inset IPA + +\begin_layout Standard +PmMn nɲN N Br RR +\end_layout + +\end_inset + + +\begin_inset IPA + +\begin_layout Standard + rFBfvTDszSZ s +\end_layout + +\end_inset + + +\begin_inset IPA + +\begin_layout Standard + zçJxGXKħQhHɬ +\end_layout + +\end_inset + + +\begin_inset IPA + +\begin_layout Standard +É®V +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +* +\end_layout + +\end_inset + +r RhÉ°l lL L +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset IPA + +\begin_layout Standard + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +! +\end_layout + +\end_inset + +o|!ǂ|| +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +! +\end_layout + +\end_inset + +b +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +! +\end_layout + +\end_inset + +d +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +! +\end_layout + +\end_inset + +j +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +! +\end_layout + +\end_inset + +g +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +! +\end_layout + +\end_inset + +Ge' +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset IPA + +\begin_layout Standard +iy1ʉW +\color red +uIY +\color inherit +Ueø987o@Eœ3ɞ2Oæ5aɶA6 +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard + +\begin_inset IPA + +\begin_layout Standard + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +* +\end_layout + +\end_inset + +ww4 HʢʡCʑɺɧ +\begin_inset IPADeco toptiebar +status open + +\begin_layout Standard +ar +\end_layout + +\end_inset + + +\begin_inset IPADeco bottomtiebar +status open + +\begin_layout Standard +tz +\end_layout + +\end_inset + + \end_layout \end_inset @@ -5712,11 +6087,83 @@ TIPA \begin_inset IPA \begin_layout Standard -[@n Ig"zA -\color red -:m -\color inherit -pl] +:;eˈˌ +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +textvertline +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +{} +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +textdoublevertline +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +{} +\end_layout + +\end_inset + +. +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +t{*} +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +{ +\end_layout + +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout +} +\end_layout + +\end_inset + + \end_layout \end_inset @@ -5729,14 +6176,14 @@ pl] \begin_inset IPA \begin_layout Standard -ls B!Y + \begin_inset ERT status collapsed \begin_layout Plain Layout \backslash -textbottomtiebar +tone \end_layout \end_inset @@ -5751,7 +6198,7 @@ status collapsed \end_inset -ae +55 \begin_inset ERT status collapsed @@ -5768,7 +6215,7 @@ status collapsed \begin_layout Plain Layout \backslash -texttoptiebar +tone \end_layout \end_inset @@ -5783,7 +6230,7 @@ status collapsed \end_inset -ar +44 \begin_inset ERT status collapsed @@ -5794,29 +6241,77 @@ status collapsed \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 -\begin_layout Standard -l +\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 -u{ö} +tone \end_layout \end_inset -e + +\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 -t{*} +tone \end_layout \end_inset @@ -5831,7 +6326,7 @@ status collapsed \end_inset - +11 \begin_inset ERT status collapsed @@ -5841,7 +6336,19 @@ status collapsed \end_inset -Ì¥ +ꜜꜛ +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +tone +\end_layout + +\end_inset + + \begin_inset ERT status collapsed @@ -5851,7 +6358,7 @@ status collapsed \end_inset -r +15 \begin_inset ERT status collapsed @@ -5861,7 +6368,19 @@ status collapsed \end_inset -̽ + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +tone +\end_layout + +\end_inset + + \begin_inset ERT status collapsed @@ -5871,11 +6390,24 @@ status collapsed \end_inset +51 +\begin_inset ERT +status collapsed -\begin_inset script superscript +\begin_layout Plain Layout +} +\end_layout -\begin_layout Standard -j +\end_inset + + +\begin_inset ERT +status collapsed + +\begin_layout Plain Layout + +\backslash +tone \end_layout \end_inset @@ -5884,25 +6416,55 @@ j \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 - d˺ + \begin_inset ERT status collapsed \begin_layout Plain Layout \backslash -H{k} +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 @@ -5924,7 +6486,7 @@ status collapsed \end_inset -55 +454 \begin_inset ERT status collapsed @@ -5934,7 +6496,7 @@ status collapsed \end_inset -e +↗ \begin_inset ERT status collapsed @@ -5956,7 +6518,7 @@ status collapsed \end_inset - + \end_layout \end_inset diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex index 187711c2bf..d84657273c 100644 --- a/src/tex2lyx/test/test-insets.tex +++ b/src/tex2lyx/test/test-insets.tex @@ -516,16 +516,69 @@ $test\vphantom{Wow\&\%}test$ \subsection{TIPA} -\textipa{[@n I\textscriptg "zA:mpl]} +\begin{IPA} +\r{e} +\textsubwedge{e} +\textsubumlaut{e} +\textsubtilde{e} +\textseagull{e} +\textsubbridge{e} +\textinvsubbridge{e} +\textsubsquare{e} +e\textsuperscript{h} +\textsubrhalfring{e} +\textsublhalfring{e} +\textsubplus{e} +\=*{e} +\b{e} +\"{e} +\textovercross{e} +\s{e} +\textsyllabic{e} +\textsubarch{e} +e\textrhoticity +e\textsuperscript{w} +e\textsuperscript{j} +e\textsuperscript{\textgamma} +e\textsuperscript{\textrevglotstop} +\textsuperimposetilde{e} +\textraising{e} +\textlowering{e} +\textadvancing{e} +\textretracting{e} +\~{e} +e\textsuperscript{n} +e\textsuperscript{l} +e\textcorner{} +\H{e} + +\`{e} +\={e} +\'{e} +\textdoublegrave{e} +\v{e} +\^{e} +\texthighrise{e} +\textlowrise{e} +\textrisefall{e} +\u{e} +\end{IPA} -\textipa{[@n Ig"zA\textcolor{red}{:m}pl]} +\textipa{pbtd\:t\:dc\textbardotlessj k\textscriptg q\;G} +\textipa{PmMn\:n\textltailn N\;N\;Br\;RR} +\textipa{\:rFBfvTDszSZ\:s} +\textipa{\:zçJxGXK\textcrh QhH\textbeltl{}} +\textipa{\textlyoghlig V\*r\:Rh\textturnmrleg l\:lL\;L} -\begin{IPA} -ls\;B!Y\textbottomtiebar{ae}\texttoptiebar{ar} +\textipa{\!o|!\textdoublebarpipe ||\!b\!d\!j\!g\!Ge'} -l\u{ö}e\t*{ }\textsubring{r}\textovercross{\textsuperscript{j}} d\textcorner{} -\H{k} \tone{55}e\textglobfall{} -\end{IPA} +\textipa{iy1\textbaru W\textcolor{red}{uIY}Ueø987o@Eœ3\textcloserevepsilon 2Oæ5a\textscoelig A6} + +\textipa{\*ww4\;H\textbarrevglotstop\textbarglotstop C\textctz\textturnlonglegr\texththeng \texttoptiebar{ar}\textbottomtiebar{tz}} + +\textipa{:;e\textprimstress\textsecstress \textvertline{}\textdoublevertline{}.\t*{ }} + +\textipa{\tone{55}\tone{44}\tone{33}\tone{22}\tone{11}\textdownstep\textupstep \tone{15}\tone{51}\tone{45}\tone{12}\tone{454}\textglobrise \textglobfall{}} \subsection{Line breaks\sindex[breaks]{Line breaks}} diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 7bf2daed64..474fcb18e6 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1417,7 +1417,6 @@ void parse_environment(Parser & p, ostream & os, bool outer, eat_whitespace(p, os, parent_context, false); parent_context.check_layout(os); begin_inset(os, "IPA\n"); - //os << "status open\n"; parse_text_in_inset(p, os, FLAG_END, outer, parent_context); end_inset(os); p.skip_spaces(); @@ -3229,6 +3228,52 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, preamble.registerAutomaticallyLoadedPackage("tipx"); } + else if (t.cs() == "texttoptiebar" || t.cs() == "textbottomtiebar") { + context.check_layout(os); + begin_inset(os, "IPADeco " + t.cs().substr(4) + "\n"); + os << "status open\n"; + parse_text_in_inset(p, os, FLAG_ITEM, outer, context); + end_inset(os); + p.skip_spaces(); + } + + // 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") { + 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) + + "}"; + set 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 << content << to_utf8(s); + for (set::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() == "phantom" || t.cs() == "hphantom" || t.cs() == "vphantom") { context.check_layout(os); -- 2.39.2