Skip to content

Instantly share code, notes, and snippets.

@egonw
Last active September 15, 2017 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egonw/da73ca91f3999eddc4433949f080920a to your computer and use it in GitHub Desktop.
Save egonw/da73ca91f3999eddc4433949f080920a to your computer and use it in GitHub Desktop.
/**
* LaTeX .bbl output.
*
* (Code contributed by Egon Willighagen, based on the prototype.text code.)
*/
CSL.Output.Formats.prototype.latex = {
"text_escape": function (text) {
if (!text) {
text = "";
}
return text;
},
"bibstart": "\\begin{thebibliography}{4}",
"bibend": "\end{thebibliography}",
"@font-style/italic": "{\\em %%STRING%%}",
"@font-style/oblique": false,
"@font-style/normal": false,
"@font-variant/small-caps": false,
"@passthrough/true": CSL.Output.Formatters.passthrough,
"@font-variant/normal": false,
"@font-weight/bold": "{\\bf %%STRING%%}",
"@font-weight/normal": false,
"@font-weight/light": false,
"@text-decoration/none": false,
"@text-decoration/underline": false,
"@vertical-align/baseline": false,
"@vertical-align/sup": false,
"@vertical-align/sub": false,
"@strip-periods/true": CSL.Output.Formatters.passthrough,
"@strip-periods/false": CSL.Output.Formatters.passthrough,
"@quotes/true": function (state, str) {
if ("undefined" === typeof str) {
return state.getTerm("open-quote");
}
return state.getTerm("open-quote") + str + state.getTerm("close-quote");
},
"@quotes/inner": function (state, str) {
if ("undefined" === typeof str) {
//
// Mostly right by being wrong (for apostrophes)
//
return "\u2019";
}
return state.getTerm("open-inner-quote") + str + state.getTerm("close-inner-quote");
},
"@quotes/false": false,
//"@bibliography/body": function (state,str){
// return "<div class=\"csl-bib-body\">\n"+str+"</div>";
//},
"@cite/entry": function (state, str) {
return state.sys.wrapCitationEntry(str, this.item_id, this.locator_txt, this.suffix_txt);
},
"@bibliography/entry": function (state, str) {
return "\\bibitem{" + state.sys.embedBibliographyEntry(this.item_id) + "}\n";
},
"@display/block": function (state, str) {
return "\n"+str;
},
"@display/left-margin": function (state, str) {
return str;
},
"@display/right-inline": function (state, str) {
return str;
},
"@display/indent": function (state, str) {
return "\n "+str;
},
"@showid/true": function (state, str, cslid) {
return str;
},
"@URL/true": function (state, str) {
return str;
},
"@DOI/true": function (state, str) {
return str;
}
};
@egonw
Copy link
Author

egonw commented Sep 15, 2017

Mind you, this code is likely very incomplete, but biased towards to list of citations I was looking at....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment