This commit is contained in:
Shan Carter
2017-01-13 13:35:29 -08:00
4 changed files with 73 additions and 27 deletions
+2
View File
@@ -15,6 +15,8 @@ export default function(dom, data) {
val = val.replace(/[\t\n ]+/g, " ");
val = val.replace(/{\\["^`\.'acu~Hvs]( )?([a-zA-Z])}/g,
(full, x, char) => char);
val = val.replace(/{\\([a-zA-Z])}/g,
(full, char) => char);
e.entryTags[k] = val;
}
bibliography[e.citationKey] = e.entryTags;
+30 -13
View File
@@ -68,16 +68,22 @@ export default function(dom, data) {
function author_string(ent, template, sep, finalSep){
var names = ent.author.split(" and ");
let name_strings = names.map(name => {
var last = name.split(",")[0].trim();
var firsts = name.split(",")[1];
name = name.trim();
if (name.indexOf(",") != -1){
var last = name.split(",")[0].trim();
var firsts = name.split(",")[1];
} else {
var last = name.split(" ").slice(-1)[0].trim();
var firsts = name.split(" ").slice(0,-1).join(" ");
}
var initials = "";
if (firsts != undefined) {
initials = firsts.trim().split(" ").map(s => s.trim()[0]);
initials = initials.join(".")+".";
}
return template.replace("F", firsts)
.replace("L", last)
.replace("I", initials);
return template.replace("${F}", firsts)
.replace("${L}", last)
.replace("${I}", initials);
});
if (names.length > 1) {
var str = name_strings.slice(0, names.length-1).join(sep);
@@ -98,21 +104,28 @@ export default function(dom, data) {
if ("pages" in ent){
cite += ", pp. " + ent.pages
}
cite += ". "
if (cite != "") cite += ". "
if ("publisher" in ent){
cite += ent.publisher + ".";
cite += ent.publisher;
if (cite[cite.length-1] != ".") cite += ".";
}
return cite;
}
function link_string(ent){
if ("url" in ent){
if (ent.url.slice(-4) == ".pdf"){
var url = ent.url;
var arxiv_match = (/arxiv\.org\/abs\/([0-9\.]*)/).exec(url);
if (arxiv_match != null){
url = `http://arxiv.org/pdf/${arxiv_match[1]}.pdf`;
}
if (url.slice(-4) == ".pdf"){
var label = "PDF";
} else if (ent.url.slice(-5) == ".html") {
} else if (url.slice(-5) == ".html") {
var label = "HTML";
}
return ` &ensp;<a href="${ent.url}">[${label||"link"}]</a>`;
return ` &ensp;<a href="${url}">[${label||"link"}]</a>`;
}/* else if ("doi" in ent){
return ` &ensp;<a href="https://doi.org/${ent.doi}" >[DOI]</a>`;
}*/ else {
@@ -129,8 +142,12 @@ export default function(dom, data) {
function bibliography_cite(ent, fancy){
if (ent){
var cite = author_string(ent, "L, I", ", ", " and ");
cite += ", " + ent.year + ". "
var cite = author_string(ent, "${L}, ${I}", ", ", " and ");
if (ent.year || ent.date){
cite += ", " + (ent.year || ent.date) + ". "
} else {
cite += ". "
}
cite += "<b>" + ent.title + "</b>. ";
cite += venue_string(ent);
cite += doi_string(ent);
@@ -147,7 +164,7 @@ export default function(dom, data) {
cite += "<b>" + ent.title + "</b>";
cite += link_string(ent);
cite += "<br>"
cite += author_string(ent, "I L", ", ") + ".<br>";
cite += author_string(ent, "${I} ${L}", ", ") + ".<br>";
cite += venue_string(ent).trim() + " " + ent.year + ". "
cite += doi_string(ent, true);
return cite
+40 -13
View File
@@ -282,6 +282,8 @@ function Type$2(tag, options) {
var type = Type$2;
/*eslint-disable max-len*/
var common$4 = common$1;
var YAMLException$3 = exception;
var Type$1 = type;
@@ -893,6 +895,8 @@ function createCommonjsModule(fn, module) {
return module = { exports: {} }, fn(module, module.exports), module.exports;
}
/*eslint-disable no-bitwise*/
var NodeBuffer;
try {
@@ -1350,6 +1354,8 @@ var default_full = Schema$6.DEFAULT = new Schema$6({
]
});
/*eslint-disable max-len,no-use-before-define*/
var common = common$1;
var YAMLException$1 = exception;
var Mark = mark;
@@ -2941,6 +2947,8 @@ var loader$1 = {
safeLoad: safeLoad_1
};
/*eslint-disable no-use-before-define*/
var common$7 = common$1;
var YAMLException$5 = exception;
var DEFAULT_FULL_SCHEMA$2 = default_full;
@@ -4208,6 +4216,8 @@ var bibliography = function(dom, data) {
val = val.replace(/[\t\n ]+/g, " ");
val = val.replace(/{\\["^`\.'acu~Hvs]( )?([a-zA-Z])}/g,
function (full, x, char) { return char; });
val = val.replace(/{\\([a-zA-Z])}/g,
function (full, char) { return char; });
e.entryTags[k] = val;
}
bibliography[e.citationKey] = e.entryTags;
@@ -5988,16 +5998,22 @@ var citation = function(dom, data) {
function author_string(ent, template, sep, finalSep){
var names = ent.author.split(" and ");
var name_strings = names.map(function (name) {
var last = name.split(",")[0].trim();
var firsts = name.split(",")[1];
name = name.trim();
if (name.indexOf(",") != -1){
var last = name.split(",")[0].trim();
var firsts = name.split(",")[1];
} else {
var last = name.split(" ").slice(-1)[0].trim();
var firsts = name.split(" ").slice(0,-1).join(" ");
}
var initials = "";
if (firsts != undefined) {
initials = firsts.trim().split(" ").map(function (s) { return s.trim()[0]; });
initials = initials.join(".")+".";
}
return template.replace("F", firsts)
.replace("L", last)
.replace("I", initials);
return template.replace("${F}", firsts)
.replace("${L}", last)
.replace("${I}", initials);
});
if (names.length > 1) {
var str = name_strings.slice(0, names.length-1).join(sep);
@@ -6018,21 +6034,28 @@ var citation = function(dom, data) {
if ("pages" in ent){
cite += ", pp. " + ent.pages;
}
cite += ". ";
if (cite != "") { cite += ". "; }
if ("publisher" in ent){
cite += ent.publisher + ".";
cite += ent.publisher;
if (cite[cite.length-1] != ".") { cite += "."; }
}
return cite;
}
function link_string(ent){
if ("url" in ent){
if (ent.url.slice(-4) == ".pdf"){
var url = ent.url;
var arxiv_match = (/arxiv\.org\/abs\/([0-9\.]*)/).exec(url);
if (arxiv_match != null){
url = "http://arxiv.org/pdf/" + (arxiv_match[1]) + ".pdf";
}
if (url.slice(-4) == ".pdf"){
var label = "PDF";
} else if (ent.url.slice(-5) == ".html") {
} else if (url.slice(-5) == ".html") {
var label = "HTML";
}
return (" &ensp;<a href=\"" + (ent.url) + "\">[" + (label||"link") + "]</a>");
return (" &ensp;<a href=\"" + url + "\">[" + (label||"link") + "]</a>");
}/* else if ("doi" in ent){
return ` &ensp;<a href="https://doi.org/${ent.doi}" >[DOI]</a>`;
}*/ else {
@@ -6049,8 +6072,12 @@ var citation = function(dom, data) {
function bibliography_cite(ent, fancy){
if (ent){
var cite = author_string(ent, "L, I", ", ", " and ");
cite += ", " + ent.year + ". ";
var cite = author_string(ent, "${L}, ${I}", ", ", " and ");
if (ent.year || ent.date){
cite += ", " + (ent.year || ent.date) + ". ";
} else {
cite += ". ";
}
cite += "<b>" + ent.title + "</b>. ";
cite += venue_string(ent);
cite += doi_string(ent);
@@ -6067,7 +6094,7 @@ var citation = function(dom, data) {
cite += "<b>" + ent.title + "</b>";
cite += link_string(ent);
cite += "<br>";
cite += author_string(ent, "I L", ", ") + ".<br>";
cite += author_string(ent, "${I} ${L}", ", ") + ".<br>";
cite += venue_string(ent).trim() + " " + ent.year + ". ";
cite += doi_string(ent, true);
return cite
+1 -1
View File
File diff suppressed because one or more lines are too long