Compare commits

...

2 Commits

Author SHA1 Message Date
Ludwig Schubert 6f7df48fc2 2.2.19 2017-12-04 16:50:48 -08:00
Ludwig Schubert 71450e9ba8 Fix crash when a citation has no authors in Meta tags transform 2017-12-04 16:50:39 -08:00
3 changed files with 17 additions and 15 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "distill-template",
"version": "2.2.18",
"version": "2.2.19",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "distill-template",
"version": "2.2.18",
"version": "2.2.19",
"description": "Template for creating Distill articles.",
"main": "dist/template.v2.js",
"bin": {
+15 -13
View File
@@ -124,26 +124,28 @@ function appendHtml(el, html) {
}
function citation_meta_content(ref){
// Special test for arxiv
var content = `citation_title=${ref.title};`;
ref.author.split(' and ').forEach(name => {
name = name.trim();
let last, firsts;
if (name.indexOf(',') != -1){
last = name.split(',')[0].trim();
firsts = name.split(',')[1].trim();
} else {
last = name.split(' ').slice(-1)[0].trim();
firsts = name.split(' ').slice(0,-1).join(' ');
}
content += `citation_author=${firsts} ${last};`;
});
if (ref.author && ref.author !== '') {
ref.author.split(' and ').forEach(name => {
name = name.trim();
let last, firsts;
if (name.indexOf(',') != -1){
last = name.split(',')[0].trim();
firsts = name.split(',')[1].trim();
} else {
last = name.split(' ').slice(-1)[0].trim();
firsts = name.split(' ').slice(0,-1).join(' ');
}
content += `citation_author=${firsts} ${last};`;
});
}
if ('year' in ref) {
content += `citation_publication_date=${ref.year};`;
}
// Special test for arxiv
let arxiv_id_search = /https?:\/\/arxiv\.org\/pdf\/([0-9]*\.[0-9]*)\.pdf/.exec(ref.url);
arxiv_id_search = arxiv_id_search || /https?:\/\/arxiv\.org\/abs\/([0-9]*\.[0-9]*)/.exec(ref.url);
arxiv_id_search = arxiv_id_search || /arXiv preprint arXiv:([0-9]*\.[0-9]*)/.exec(ref.journal);