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.
This commit is contained in:
Julien Rioux 2013-01-10 15:24:53 +01:00
parent b57f585109
commit 15b2501177
5 changed files with 40 additions and 29 deletions

View 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%]]}

View 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%
!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%
!startlink {!<a href='#LyXCite-%key%'>!}
!endlink {!</a>!}
!nextcite {%next%[[%!sep% %!shortauthor%%!textafter2%%!nextcite%]]}
!nextcitetitle {%next%[[%!sep% %!shortauthor%%!shorttitle%%!textafter2%%!nextcitetitle%]]}
!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%%!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% %!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%]]}

View 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

View 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

View 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>";
}