From: Julien Rioux Date: Thu, 10 Jan 2013 14:24:53 +0000 (+0100) Subject: LyXHTML linking from citation to bib entry for LyX 2.1 (fixes #8490). X-Git-Tag: 2.1.0beta1~949 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=15b250117788fb0947557fac0dc576917069b82e;p=lyx.git LyXHTML linking from citation to bib entry for LyX 2.1 (fixes #8490). 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. --- diff --git a/lib/layouts/basic.module b/lib/layouts/basic.module index ed0e12cbbd..c168572229 100644 --- a/lib/layouts/basic.module +++ b/lib/layouts/basic.module @@ -27,7 +27,10 @@ CiteFormat default !sep , !close ] - !cite {%label%[[%label%]][[#%key%]]}%!nextcite% + !startlink {!!} + !endlink {!!} + + !cite %!startlink%{%label%[[%label%]][[#%key%]]}%!endlink%%!nextcite% !nextcite {%next%[[%!sep% %!cite%]]} !nexthashkey {%next%[[%!sep% #%key%%!nexthashkey%]]} diff --git a/lib/layouts/jurabib.module b/lib/layouts/jurabib.module index 4748c60613..63e016e51a 100644 --- a/lib/layouts/jurabib.module +++ b/lib/layouts/jurabib.module @@ -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 {!!} + !endlink {!!} + + !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%]]} diff --git a/lib/layouts/natbib.module b/lib/layouts/natbib.module index cf2c0d8cd8..65d6b39ff1 100644 --- a/lib/layouts/natbib.module +++ b/lib/layouts/natbib.module @@ -49,9 +49,12 @@ CiteFormat default !sep , !close ] - !nextauthor {%next%[[%!sep% %!abbrvauthor%%!nextauthor%]]} + !startlink {!!} + !endlink {!!} + + !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 diff --git a/src/BiblioInfo.cpp b/src/BiblioInfo.cpp index a2989995d2..6e5bf6dbf2 100644 --- a/src/BiblioInfo.cpp +++ b/src/BiblioInfo.cpp @@ -496,9 +496,11 @@ docstring BibTeXInfo::expandFormat(string const & format, } else { docstring const val = getValueForKey(key, before, after, dialog, xref, lang); - ret += from_ascii("{!!}"); + if (!scanning_rich) + ret += from_ascii("{!!}"); ret += val; - ret += from_ascii("{!!}"); + if (!scanning_rich) + ret += from_ascii("{!!}"); } } else { // beginning of key diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index fdd6e0ba1b..d5c43535b1 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -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 "" + + return "" + html::htmlize(content, XHTMLStream::ESCAPE_ALL) + ""; }