Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not format author names enclosed in curly brackets #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/helpers/bibtex.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function normalizeTag(string) {
.replace(/[\t\n ]+/g, ' ')
.replace(/{\\["^`.'acu~Hvs]( )?([a-zA-Z])}/g, (full, x, char) => char)
.replace(/{\\([a-zA-Z])}/g, (full, char) => char)
.replace(/[{}]/gi,''); // Replace curly braces forcing plaintext in latex.
}

export function parseBibtex(bibtex) {
Expand Down
11 changes: 8 additions & 3 deletions src/helpers/citation.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ function author_string(ent, template, sep, finalSep) {
var names = ent.author.split(" and ");
let name_strings = names.map(name => {
name = name.trim();
if (name.match(/\{.+\}/)) {
var regExp = /\{([^}]+)\}/;
var matches = regExp.exec(name);
return matches[1];
}
if (name.indexOf(",") != -1) {
var last = name.split(",")[0].trim();
var firsts = name.split(",")[1];
Expand Down Expand Up @@ -114,7 +119,7 @@ function venue_string(ent) {
cite += ent.publisher;
if (cite[cite.length - 1] != ".") cite += ".";
}
return cite;
return cite.replace(/[{}]/gi,'');
}

function link_string(ent) {
Expand Down Expand Up @@ -148,7 +153,7 @@ function doi_string(ent, new_line) {
}

function title_string(ent) {
return '<span class="title">' + ent.title + "</span> ";
return '<span class="title">' + ent.title.replace(/[{}]/gi,'') + "</span> ";
}

export function bibliography_cite(ent, fancy) {
Expand Down Expand Up @@ -188,7 +193,7 @@ export function bibliography_cite(ent, fancy) {
export function hover_cite(ent) {
if (ent) {
var cite = "";
cite += "<strong>" + ent.title + "</strong>";
cite += "<strong>" + ent.title.replace(/[{}]/gi,'') + "</strong>";
cite += link_string(ent);
cite += "<br>";

Expand Down
11 changes: 8 additions & 3 deletions src/transforms/citation.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ export default function(dom, data) {
var names = ent.author.split(' and ');
let name_strings = names.map(name => {
name = name.trim();
if (name.match(/\{.+\}/)) {
var regExp = /\{([^}]+)\}/;
var matches = regExp.exec(name);
return matches[1];
}
if (name.indexOf(',') != -1){
var last = name.split(',')[0].trim();
var firsts = name.split(',')[1];
Expand Down Expand Up @@ -153,7 +158,7 @@ export default function(dom, data) {
cite += ent.publisher;
if (cite[cite.length-1] != '.') cite += '.';
}
return cite;
return cite.replace(/[{}]/gi,'');
}

function link_string(ent){
Expand Down Expand Up @@ -186,7 +191,7 @@ export default function(dom, data) {

function bibliography_cite(ent, fancy){
if (ent){
var cite = '<b>' + ent.title + '</b> ';
var cite = '<b>' + ent.title.replace(/[{}]/gi,'') + '</b> ';
cite += link_string(ent) + '<br>';
cite += author_string(ent, '${L}, ${I}', ', ', ' and ');
if (ent.year || ent.date){
Expand Down Expand Up @@ -216,7 +221,7 @@ export default function(dom, data) {
function hover_cite(ent){
if (ent){
var cite = '';
cite += '<b>' + ent.title + '</b>';
cite += '<b>' + ent.title.replace(/[{}]/gi,'') + '</b>';
cite += link_string(ent);
cite += '<br>';

Expand Down