The branch, master, has been updated.

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

commit a2022d457b997ecd694ef1a4bfad87c8a2e28ad3
Author: Uwe Stöhr <[email protected]>
Date:   Sun Feb 17 04:17:02 2013 +0100

    tex2lyx: support bibtex inset with \phantomsection
    
    This is an addendum to [72a44b3c/lyxgit] because depending on the 
environment, LyX adds a \phantomsection before \addcontentsline.
    
    - also update the test file

diff --git a/src/tex2lyx/test/test-insets.lyx.lyx 
b/src/tex2lyx/test/test-insets.lyx.lyx
index bfc85c3..cbe3736 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -6135,8 +6135,14 @@ $
 .
 \end_layout
 
-\begin_layout Standard
+\begin_layout Section
+Lists/Indices
+\end_layout
 
+\begin_layout Standard
+single 
+\backslash
+addcontentsline: 
 \begin_inset ERT
 status collapsed
 
@@ -6152,10 +6158,18 @@ addcontentsline{toc}{section}{test}
 \end_layout
 
 \begin_layout Standard
-  
+with 
+\backslash
+addcontentsline and 
+\backslash
+phantomsection:
+\end_layout
+
+\begin_layout Standard
+ 
 \begin_inset CommandInset bibtex
 LatexCommand bibtex
-bibfiles "IEEEexample"
+bibfiles "xampl"
 options "bibtotoc,test"
 
 \end_inset
@@ -6164,10 +6178,14 @@ options "bibtotoc,test"
 \end_layout
 
 \begin_layout Standard
+normal:
+\end_layout
+
+\begin_layout Standard
  
 \begin_inset CommandInset bibtex
 LatexCommand bibtex
-bibfiles "IEEEexample"
+bibfiles "xampl"
 options "test"
 
 \end_inset
@@ -6176,6 +6194,12 @@ options "test"
 \end_layout
 
 \begin_layout Standard
+with wrong 
+\backslash
+addcontentsline:
+\end_layout
+
+\begin_layout Standard
 
 \begin_inset ERT
 status collapsed
@@ -6200,10 +6224,10 @@ addcontentsline{toc}{section}{test}
 
 \end_inset
 
- 
+  
 \begin_inset CommandInset bibtex
 LatexCommand bibtex
-bibfiles "IEEEexample"
+bibfiles "xampl"
 options "test"
 
 \end_inset
@@ -6212,6 +6236,31 @@ options "test"
 \end_layout
 
 \begin_layout Standard
+with 
+\backslash
+addcontentsline and 
+\backslash
+nocite{*}:
+\end_layout
+
+\begin_layout Standard
+  
+\begin_inset CommandInset bibtex
+LatexCommand bibtex
+btprint "btPrintAll"
+bibfiles "xampl"
+options "bibtotoc,test"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+normal index:
+\end_layout
+
+\begin_layout Standard
 
 \begin_inset CommandInset index_print
 LatexCommand printindex
@@ -6223,6 +6272,10 @@ type "idx"
 \end_layout
 
 \begin_layout Standard
+normal nomenclature:
+\end_layout
+
+\begin_layout Standard
 
 \begin_inset CommandInset nomencl_print
 LatexCommand printnomenclature
@@ -6234,7 +6287,7 @@ hello
 \end_layout
 
 \begin_layout Standard
-
+manually set width: 
 \begin_inset ERT
 status collapsed
 
@@ -6259,6 +6312,10 @@ set_width "none"
 \end_layout
 
 \begin_layout Standard
+nomenclature with set width:
+\end_layout
+
+\begin_layout Standard
 
 \begin_inset CommandInset nomencl_print
 LatexCommand printnomenclature
diff --git a/src/tex2lyx/test/test-insets.tex b/src/tex2lyx/test/test-insets.tex
index ff2251a..9d70ad8 100644
--- a/src/tex2lyx/test/test-insets.tex
+++ b/src/tex2lyx/test/test-insets.tex
@@ -541,6 +541,7 @@ or by a page break \pagebreak
 or by a defined page break \pagebreak % again with a comment
        [4]
 
+
 \section{Special characters\index{Special characters}}
 
 Then one has those macros with a long name for a short meaning, like
@@ -570,6 +571,7 @@ builtin \textasciicircum % with a comment
 A sub\textsubscript{sc\emph{ript}} and super\textsuperscript{script
 with $a^2+b^2=c^2$ math}.
 
+
 \section{Mathematics\index{Mathematics}}
 
 Let $f:\left[  a,b\right]  \rightarrow%
@@ -579,25 +581,47 @@ Let $f:\left[  a,b\right]  \rightarrow%
 %EndExpansion
 $.
 
-\addcontentsline{toc}{section}{test}
+
+\section{Lists/Indices}
+
+single \textbackslash{}addcontentsline: \addcontentsline{toc}{section}{test}
+
+with \textbackslash{}addcontentsline and \textbackslash{}phantomsection:
 
 \bibliographystyle{test}
-\addcontentsline{toc}{section}{\refname}
-\bibliography{IEEEexample}
+\phantomsection\addcontentsline{toc}{section}{\refname}\bibliography{xampl}
+
+
+normal:
 
 \bibliographystyle{test}
-\bibliography{IEEEexample}
+\bibliography{xampl}
+
+
+with wrong \textbackslash{}addcontentsline:
+
+\bibliographystyle{test} \addcontentsline{toc}{section}{test} 
\bibliographystyle{test}
+\bibliography{xampl}
+
+
+with \textbackslash{}addcontentsline and \textbackslash{}nocite\{{*}\}:
 
 \bibliographystyle{test}
-\addcontentsline{toc}{section}{test}
-\bibliography{IEEEexample}
+\addcontentsline{toc}{section}{\refname}\nocite{*}
+\bibliography{xampl}
+
+
+normal index:
 
 \printindex{}
 
+normal nomenclature:
+
 \printnomenclature hello
 
-\settowidth{\nomlabelwidth}{URL2}
-\printnomenclature{}
+manually set width: \settowidth{\nomlabelwidth}{URL2} \printnomenclature{}
+
+nomenclature with set width:
 
 \printnomenclature[0.02\linewidth]{}
 
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index 4908e88..6ac1888 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -3990,6 +3990,10 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                                                continue;
                                } else if (t2.cs() == "bibliography")
                                        output = false;
+                               else if (t2.cs() == "phantomsection") {
+                                       output = false;
+                                       continue;
+                               }
                                else if (t2.cs() == "addcontentsline") {
                                        // get the 3 arguments of 
\addcontentsline
                                        p.getArg('{', '}');
@@ -4009,6 +4013,13 @@ void parse_text(Parser & p, ostream & os, unsigned 
flags, bool outer,
                        }
                }
 
+               else if (t.cs() == "phantomsection") {
+                       // we only support this if it occurs between
+                       // \bibliographystyle and \bibliography
+                       if (bibliographystyle.empty())
+                               output_ert_inset(os, "\\phantomsection", 
context);
+               }
+
                else if (t.cs() == "addcontentsline") {
                        context.check_layout(os);
                        // get the 3 arguments of \addcontentsline
@@ -4046,6 +4057,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, 
bool outer,
                                        BibOpts = bibliographystyle;
                                else
                                        BibOpts = BibOpts + ',' + 
bibliographystyle;
+                               // clear it because each bibtex entry has its 
style
+                               // and we need an empty string to handle 
\phantomsection
+                               bibliographystyle.clear();
                        }
                        os << "options " << '"' << BibOpts << '"' << "\n";
                        end_inset(os);

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

Summary of changes:
 src/tex2lyx/test/test-insets.lyx.lyx |   71 ++++++++++++++++++++++++++++++---
 src/tex2lyx/test/test-insets.tex     |   40 +++++++++++++++----
 src/tex2lyx/text.cpp                 |   14 +++++++
 3 files changed, 110 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
The LyX Source Repository

Reply via email to