The branch, master, has been updated.

- Log -----------------------------------------------------------------

commit a99241266b1ad0cefd0f96a95b9793c9617df4ca
Author: Uwe Stöhr <[email protected]>
Date:   Sun Feb 17 03:15:24 2013 +0100

    tex2lyx/Preamble.cpp: proper handling of the refstyle preamble code
    
    - also rename the test file because it is also an excellent test file for 
the theorem environments - which are not yet supported by tex2lyx

diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp
index 7e902c6..fead3b1 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -1370,6 +1370,66 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
                        p.setCatcode('@', catOther);
                }
 
+               else if (t.cs() == "RS@ifundefined") {
+                       string const name = p.verbatim_item();
+                       string const body1 = p.verbatim_item();
+                       string const body2 = p.verbatim_item();
+                       // store the in_lyx_preamble setting
+                       bool const was_in_lyx_preamble = in_lyx_preamble;
+                       if (name == "subref"
+                               || name == "thmref"
+                               || name == "lemref") {
+                               p.skip_spaces();
+                               
preamble.registerAutomaticallyLoadedPackage("refstyle");
+                               in_lyx_preamble = true;
+                       }
+                       // only non-lyxspecific stuff
+                       if (!in_lyx_preamble) {
+                               ostringstream ss;
+                               ss << '\\' << t.cs();
+                               ss << '{' << name << '}'
+                                  << '{' << body1 << '}'
+                                  << '{' << body2 << '}';
+                               h_preamble << ss.str();
+                       }
+                       // restore the in_lyx_preamble setting
+                       in_lyx_preamble = was_in_lyx_preamble;
+               }
+               
+               else if (t.cs() == "AtBeginDocument") {
+                       string const name = p.verbatim_item();
+                       // store the in_lyx_preamble setting
+                       bool const was_in_lyx_preamble = in_lyx_preamble;
+                       if (name == 
"\\providecommand\\partref[1]{\\ref{part:#1}}"
+                               || name == 
"\\providecommand\\chapref[1]{\\ref{chap:#1}}"
+                               || name == 
"\\providecommand\\secref[1]{\\ref{sec:#1}}"
+                               || name == 
"\\providecommand\\subref[1]{\\ref{sub:#1}}"
+                               || name == 
"\\providecommand\\parref[1]{\\ref{par:#1}}"
+                               || name == 
"\\providecommand\\figref[1]{\\ref{fig:#1}}"
+                               || name == 
"\\providecommand\\tabref[1]{\\ref{tab:#1}}"
+                               || name == 
"\\providecommand\\algref[1]{\\ref{alg:#1}}"
+                               || name == 
"\\providecommand\\fnref[1]{\\ref{fn:#1}}"
+                               || name == 
"\\providecommand\\enuref[1]{\\ref{enu:#1}}"
+                               || name == 
"\\providecommand\\eqref[1]{\\ref{eq:#1}}"
+                               || name == 
"\\providecommand\\lemref[1]{\\ref{lem:#1}}"
+                               || name == 
"\\providecommand\\thmref[1]{\\ref{thm:#1}}"
+                               || name == 
"\\providecommand\\corref[1]{\\ref{cor:#1}}"
+                               || name == 
"\\providecommand\\propref[1]{\\ref{prop:#1}}") {
+                               p.skip_spaces();
+                               
preamble.registerAutomaticallyLoadedPackage("refstyle");
+                               in_lyx_preamble = true;
+                       }
+                       // only non-lyxspecific stuff
+                       if (!in_lyx_preamble) {
+                               ostringstream ss;
+                               ss << '\\' << t.cs();
+                               ss << '{' << name << '}';
+                               h_preamble << ss.str();
+                       }
+                       // restore the in_lyx_preamble setting
+                       in_lyx_preamble = was_in_lyx_preamble;
+               }
+
                else if (t.cs() == "newcommand" || t.cs() == "newcommandx"
                      || t.cs() == "renewcommand" || t.cs() == "renewcommandx"
                      || t.cs() == "providecommand" || t.cs() == 
"providecommandx"
@@ -1414,7 +1474,6 @@ void Preamble::parse(Parser & p, string const & 
forceclass,
                                p.skip_spaces();
                                in_lyx_preamble = true;
                        }
-
                        if (name == "\\bfdefault")
                                // LyX re-adds this if a kurier font is used
                                if (is_known(h_font_sans, known_kurier_fonts) 
&& body == "b") {
diff --git a/src/tex2lyx/test/test-refstyle-references.lyx.lyx 
b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
similarity index 90%
rename from src/tex2lyx/test/test-refstyle-references.lyx.lyx
rename to src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
index 06075ab..d6411a6 100644
--- a/src/tex2lyx/test/test-refstyle-references.lyx.lyx
+++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
@@ -1,44 +1,20 @@
 #LyX file created by tex2lyx 2.1.0dev
-\lyxformat 461
+\lyxformat 462
 \begin_document
 \begin_header
 \textclass book
 \begin_preamble
-\usepackage{refstyle}
 
 
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
 
-\AtBeginDocument{\providecommand{\partref}[1]{\ref{part:#1}}}
-\AtBeginDocument{\providecommand{\chapref}[1]{\ref{chap:#1}}}
-\AtBeginDocument{\providecommand{\secref}[1]{\ref{sec:#1}}}
-\AtBeginDocument{\providecommand{\subref}[1]{\ref{sub:#1}}}
-\AtBeginDocument{\providecommand{\parref}[1]{\ref{par:#1}}}
-\AtBeginDocument{\providecommand{\figref}[1]{\ref{fig:#1}}}
-\AtBeginDocument{\providecommand{\tabref}[1]{\ref{tab:#1}}}
-\AtBeginDocument{\providecommand{\algref}[1]{\ref{alg:#1}}}
-\AtBeginDocument{\providecommand{\fnref}[1]{\ref{fn:#1}}}
-\AtBeginDocument{\providecommand{\enuref}[1]{\ref{enu:#1}}}
-\AtBeginDocument{\providecommand{\eqref}[1]{\ref{eq:#1}}}
-\AtBeginDocument{\providecommand{\lemref}[1]{\ref{lem:#1}}}
-\AtBeginDocument{\providecommand{\thmref}[1]{\ref{thm:#1}}}
-\AtBeginDocument{\providecommand{\corref}[1]{\ref{cor:#1}}}
-\AtBeginDocument{\providecommand{\propref}[1]{\ref{prop:#1}}}
 \floatstyle{ruled}
 \newfloat{algorithm}{tbp}{loa}[chapter]
 \providecommand{\algorithmname}{Algorithm}
 \floatname{algorithm}{\protect\algorithmname}
-\RS@ifundefined{subref}
-  {\def\RSsubtxt{section~}\newref{sub}{name = \RSsubtxt}}
-  {}
-\RS@ifundefined{thmref}
-  {\def\RSthmtxt{theorem~}\newref{thm}{name = \RSthmtxt}}
-  {}
-\RS@ifundefined{lemref}
-  {\def\RSlemtxt{lemma~}\newref{lem}{name = \RSlemtxt}}
-  {}
+
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
diff --git a/src/tex2lyx/test/test-refstyle-references.tex 
b/src/tex2lyx/test/test-refstyle-theorems.tex
similarity index 100%
rename from src/tex2lyx/test/test-refstyle-references.tex
rename to src/tex2lyx/test/test-refstyle-theorems.tex

-----------------------------------------------------------------------

Summary of changes:
 src/tex2lyx/Preamble.cpp                           |   61 +++++++++++++++++++-
 ...nces.lyx.lyx => test-refstyle-theorems.lyx.lyx} |   28 +--------
 ...e-references.tex => test-refstyle-theorems.tex} |    0
 3 files changed, 62 insertions(+), 27 deletions(-)
 rename src/tex2lyx/test/{test-refstyle-references.lyx.lyx => 
test-refstyle-theorems.lyx.lyx} (90%)
 rename src/tex2lyx/test/{test-refstyle-references.tex => 
test-refstyle-theorems.tex} (100%)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to