]> git.lyx.org Git - lyx.git/commitdiff
LyXHTML linking from citation to bib entry for LyX 2.1 (fixes #8490).
authorJulien Rioux <jrioux@lyx.org>
Thu, 10 Jan 2013 14:24:53 +0000 (15:24 +0100)
committerJulien Rioux <jrioux@lyx.org>
Thu, 10 Jan 2013 14:32:00 +0000 (15:32 +0100)
What was previously accomplished by wrapCitation is now customizable in the
layout files. What we provide by default here corresponds roughly to the
LyX 2.0 behavior.

lib/layouts/basic.module
lib/layouts/jurabib.module
lib/layouts/natbib.module
src/BiblioInfo.cpp
src/insets/InsetCitation.cpp

index ed0e12cbbd217fc638411cc8ca3f0616723b9531..c16857222920cfcafdca4e79f3139238b6e3f273 100644 (file)
@@ -27,7 +27,10 @@ CiteFormat default
        !sep ,
        !close ]
 
-       !cite {%label%[[%label%]][[#%key%]]}%!nextcite%
+       !startlink {!<a href='#LyXCite-%key%'>!}
+       !endlink {!</a>!}
+
+       !cite %!startlink%{%label%[[%label%]][[#%key%]]}%!endlink%%!nextcite%
 
        !nextcite {%next%[[%!sep% %!cite%]]}
        !nexthashkey {%next%[[%!sep% #%key%%!nexthashkey%]]}
index 4748c60613d4de27eb333d4dd5b57a54ffbea29e..63e016e51a589023811f0f368dcf54c55eec3294 100644 (file)
@@ -58,18 +58,21 @@ CiteFormat authoryear
        !sep ;
        !close )
 
-       !cite %!shortauthor%%!textbefore2%%!textafter2%%!nextcite%
-       !citetitle %!shortauthor%%!textbefore2%%!shorttitle%%!textafter2%%!nextcitetitle%
-       !citet %!textbefore%%!shortauthor% %!open%%!year%%!textafter%%!close%%!nextcitet%
+       !startlink {!<a href='#LyXCite-%key%'>!}
+       !endlink {!</a>!}
+
+       !cite %!startlink%%!shortauthor%%!endlink%%!textbefore2%%!textafter2%%!nextcite%
+       !citetitle %!startlink%%!shortauthor%%!endlink%%!textbefore2%%!shorttitle%%!textafter2%%!nextcitetitle%
+       !citet %!textbefore%%!startlink%%!shortauthor%%!endlink% %!open%%!year%%!textafter%%!close%%!nextcitet%
        !citep %!open%%!citealp%%!close%
-       !citealt %!textbefore%%!shortauthor% %!year%%!textafter%%!nextcitealt%
-       !citealp %!textbefore%%!shortauthor%, %!year%%!textafter%%!nextcitealp%
-       !citeauthor %!textbefore%%!shortauthor%%!textafter%%!nextauthor%
-       !citeyear %!textbefore%%!year%%!textafter%%!nextyear%
-       !citeyearpar %!textbefore%%!open%%!year%%!close%%!textafter%%!nextyearpar%
+       !citealt %!textbefore%%!startlink%%!shortauthor% %!year%%!endlink%%!textafter%%!nextcitealt%
+       !citealp %!textbefore%%!startlink%%!shortauthor%, %!year%%!endlink%%!textafter%%!nextcitealp%
+       !citeauthor %!textbefore%%!startlink%%!shortauthor%%!endlink%%!textafter%%!nextauthor%
+       !citeyear %!textbefore%%!startlink%%!year%%!endlink%%!textafter%%!nextyear%
+       !citeyearpar %!textbefore%%!open%%!startlink%%!year%%!endlink%%!close%%!textafter%%!nextyearpar%
 
-       !nextcite {%next%[[%!sep% %!shortauthor%%!textafter2%%!nextcite%]]}
-       !nextcitetitle {%next%[[%!sep% %!shortauthor%%!shorttitle%%!textafter2%%!nextcitetitle%]]}
+       !nextcite {%next%[[%!sep% %!startlink%%!shortauthor%%!endlink%%!textafter2%%!nextcite%]]}
+       !nextcitetitle {%next%[[%!sep% %!startlink%%!shortauthor%%!endlink%%!shorttitle%%!textafter2%%!nextcitetitle%]]}
        !nextcitet {%next%[[%!sep% %!citet%]]}
        !nextcitealt {%next%[[%!sep% %!citealt%]]}
        !nextcitealp {%next%[[%!sep% %!citealp%]]}
index cf2c0d8cd82dc39d43c25025090c498514455c42..65d6b39ff1b373d592dd413831152ac4e7befd5b 100644 (file)
@@ -49,9 +49,12 @@ CiteFormat default
        !sep ,
        !close ]
 
-       !nextauthor {%next%[[%!sep% %!abbrvauthor%%!nextauthor%]]}
+       !startlink {!<a href='#LyXCite-%key%'>!}
+       !endlink {!</a>!}
+
+       !nextauthor {%next%[[%!sep% %!startlink%%!abbrvauthor%%!endlink%%!nextauthor%]]}
        !nextkey {%next%[[%!sep% %key%%!nextkey%]]}
-       !nextyear {%next%[[%!sep% %!year%%!nextyear%]]}
+       !nextyear {%next%[[%!sep% %!startlink%%!year%%!endlink%%!nextyear%]]}
 
        !abbrvauthor {%abbrvauthor%[[%abbrvauthor%]][[??]]}
        !textbefore {%textbefore%[[%textbefore% ]]}
@@ -61,14 +64,14 @@ CiteFormat default
        # cite styles
        citet %!citet%%!textafter%%!close%
        citealt %!citealt%%!textafter%
-       citeyearpar %!open%%!textbefore%%!year%%!nextyear%%!textafter%%!close%
+       citeyearpar %!open%%!textbefore%%!startlink%%!year%%!endlink%%!nextyear%%!textafter%%!close%
        nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
 End
 
 CiteFormat authoryear
-       !citet %!abbrvauthor% %!open%%!textbefore%%!year%%!nextcitet%
-       !citealt %!abbrvauthor% %!textbefore%%!year%%!nextcitealt%
-       !citealp %!abbrvauthor%, %!year%%!nextcitealp%
+       !citet %!startlink%%!abbrvauthor%%!endlink% %!open%%!textbefore%%!year%%!nextcitet%
+       !citealt %!startlink%%!abbrvauthor% %!textbefore%%!year%%!endlink%%!nextcitealt%
+       !citealp %!startlink%%!abbrvauthor%, %!year%%!endlink%%!nextcitealp%
 
        !nextcitet {%next%[[%!close%%!sep% %!citet%]]}
        !nextcitealt {%next%[[%!sep% %!citealt%]]}
@@ -77,24 +80,24 @@ CiteFormat authoryear
        cite %!citet%%!textafter%%!close%
        citep %!open%%!textbefore%%!citealp%%!textafter%%!close%
        citealp %!textbefore%%!citealp%%!textafter%
-       citeauthor %!abbrvauthor%%!nextauthor%%!textafter%
-       citeyear %!year%%!nextyear%%!textafter%
+       citeauthor %!startlink%%!abbrvauthor%%!endlink%%!nextauthor%%!textafter%
+       citeyear %!startlink%%!year%%!endlink%%!nextyear%%!textafter%
 End
 
 CiteFormat numerical
-       !citet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[#%key%]]}%!nextcitet%
-       !citealt %!abbrvauthor% %!textbefore%{%dialog%[[#ID]][[#%key%]]}%!nextcitealt%
+       !citet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%#%key%%!endlink%]]}%!nextcitet%
+       !citealt %!abbrvauthor% %!textbefore%{%dialog%[[#ID]][[%!startlink%#%key%%!endlink%]]}%!nextcitealt%
 
-       !hashkey {%dialog%[[#ID]][[#%key%%!nexthashkey%]]}
+       !hashkey {%dialog%[[#ID]][[%!startlink%#%key%%!endlink%%!nexthashkey%]]}
 
        !nextcitet {%next%[[%!close%%!sep% %!citet%]]}
        !nextcitealt {%next%[[%!sep% %!citealt%]]}
        !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]}
-       !nexthashkey {%next%[[%!sep% #%key%%!nexthashkey%]]}
+       !nexthashkey {%next%[[%!sep% %!startlink%#%key%%!endlink%%!nexthashkey%]]}
 
        cite %!open%%!textbefore%%!hashkey%%!textafter%%!close%
        citep %!open%%!textbefore%%!hashkey%%!textafter%%!close%
        citealp %!textbefore%%!hashkey%%!textafter%
-       citeauthor %!abbrvauthor%%!nextauthor%
-       citeyear %!year%%!nextyear%
+       citeauthor %!startlink%%!abbrvauthor%%!endlink%%!nextauthor%
+       citeyear %!startlink%%!year%%!endlink%%!nextyear%
 End
index a2989995d2da5a6b82df59eb09ec47c3045065ea..6e5bf6dbf29e0ac9eafd1af4fcb7ea2006d2fc32 100644 (file)
@@ -496,9 +496,11 @@ docstring BibTeXInfo::expandFormat(string const & format,
                                } else {
                                        docstring const val =
                                                getValueForKey(key, before, after, dialog, xref, lang);
-                                       ret += from_ascii("{!<span class=\"bib-" + key + "\">!}");
+                                       if (!scanning_rich)
+                                               ret += from_ascii("{!<span class=\"bib-" + key + "\">!}");
                                        ret += val;
-                                       ret += from_ascii("{!</span>!}");
+                                       if (!scanning_rich)
+                                               ret += from_ascii("{!</span>!}");
                                }
                        } else {
                                // beginning of key
index fdd6e0ba1bace0ad0e69761939cd58610033ea45..d5c43535b101a79a706b559e066b25b8de12f90e 100644 (file)
@@ -184,7 +184,7 @@ inline docstring wrapCitation(docstring const & key,
                return content;
        // we have to do the escaping here, because we will ultimately
        // write this as a raw string, so as not to escape the tags.
-       return "<a href='#" + key + "'>" +
+       return "<a href='#LyXCite-" + key + "'>" +
                        html::htmlize(content, XHTMLStream::ESCAPE_ALL) + "</a>";
 }