commit 7e69ac220dd958b57ec40f198355c7e0ba8d720e
Author: Uwe Stöhr <[email protected]>
Date:   Mon Dec 1 02:57:12 2014 +0100

    tex2lyx: support for KOMA-script's \caption* commands
    
    - To my knowledge tex2lyx supports now all caption constructs provided by 
LyX.
    - InsetArgument is correct here, I therefore deleted the FIXME.

diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt
index eb599bc..5119270 100644
--- a/src/tex2lyx/TODO.txt
+++ b/src/tex2lyx/TODO.txt
@@ -72,7 +72,6 @@ Format LaTeX feature                        LyX feature
        \frametitle<overlay>[short}{long}
 456    memoir: \epigraph{text}{source}      layout Epigraph, InsetArgument
 457    automatic stackrel loading           \use_package stackrel
-458    Extended InsetCaption syntax         InsetCaption
 459    beamer: \begin{frame},               \begin_layout Frame
        \begin{frame}[plain],                \begin_layout PlainFrame
        \begin{frame}[fragile]               \begin_layout FragileFrame
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 7c72b64..3f9446a 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -2828,7 +2828,8 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                                
preamble.registerAutomaticallyLoadedPackage(*it);
                }
 
-               else if (t.cs() == "caption") {
+               else if (t.cs() == "caption" || t.cs() == "captionabove" ||
+                       t.cs() == "captionbelow") {
                        bool starred = false;
                        if (p.next_token().asInput() == "*") {
                                p.get_token();
@@ -2837,14 +2838,16 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                        p.skip_spaces();
                        context.check_layout(os);
                        p.skip_spaces();
-                       if (starred)
+                       if (starred && t.cs() == "caption")
                                begin_inset(os, "Caption LongTableNoNumber\n");
-                       else
+                       else if (t.cs() == "caption")
                                begin_inset(os, "Caption Standard\n");
+                       else if (t.cs() == "captionabove")
+                               begin_inset(os, "Caption Above\n");
+                       else if (t.cs() == "captionbelow")
+                               begin_inset(os, "Caption Below\n");
                        Context newcontext(true, context.textclass, 0, 0, 
context.font);
                        newcontext.check_layout(os);
-                       // FIXME InsetArgument is now properly implemented in 
InsetLayout
-                       //       (for captions, but also for others)
                        if (p.next_token().cat() != catEscape &&
                            p.next_token().character() == '[') {
                                p.get_token(); // eat '['
@@ -3427,15 +3430,26 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                else if (is_known(t.cs(), known_phrases) ||
                         (t.cs() == "protect" &&
                          p.next_token().cat() == catEscape &&
-                         is_known(p.next_token().cs(), known_phrases))) {
-                       // LyX sometimes puts a \protect in front, so we have 
to ignore it
-                       // FIXME: This needs to be changed when bug 4752 is 
fixed.
-                       where = is_known(
-                               t.cs() == "protect" ? p.get_token().cs() : 
t.cs(),
-                               known_phrases);
-                       context.check_layout(os);
-                       os << known_coded_phrases[where - known_phrases];
-                       skip_spaces_braces(p);
+                         is_known(p.next_token().cs(), known_phrases)) ||
+                                (t.cs() == "protect" &&
+                             (p.next_token().cs() == "caption" ||
+                                  p.next_token().cs() == "captionabove" ||
+                                  p.next_token().cs() == "captionbelow"))) {
+                       if (p.next_token().cs() == "caption" ||
+                               p.next_token().cs() == "captionabove" ||
+                               p.next_token().cs() == "captionbelow")
+                               // we must ignore if \protect is in front of 
\caption*
+                               ;
+                       else {
+                               // LyX sometimes puts a \protect in front, so 
we have to ignore it
+                               // FIXME: This needs to be changed when bug 
4752 is fixed.
+                               where = is_known(
+                                       t.cs() == "protect" ? 
p.get_token().cs() : t.cs(),
+                                       known_phrases);
+                               context.check_layout(os);
+                               os << known_coded_phrases[where - 
known_phrases];
+                               skip_spaces_braces(p);
+                       }
                }
 
                // handle refstyle first to catch \eqref which can also occur

Reply via email to