Skip to content

Commit

Permalink
[LXL-3929] Don't replace '.,' with '.' inside values when creating label
Browse files Browse the repository at this point in the history
  • Loading branch information
olovy committed Oct 6, 2022
1 parent c2435b7 commit 0827903
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lxljs/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ function formatLabel(item, type, resources) {
// FIXME: this should be driven by display.jsonld
// We don't want Library and Bibliography. Could do isSubclassOf('Agent') && !isSubclassOf('Collection') but hardcode the list for now
const isAgent = ['Person', 'Organization', 'Jurisdiction', 'Meeting', 'Family'].includes(type);
const separator = isAgent ? ', ' : ' • ';
// We don't want to touch commas inside property values when doing the final cleanup.
// Use a private use character as a temporary stand in for comma.
const separator = isAgent ? '\uE000 ' : ' • ';

const objKeys = Object.keys(item);
for (let i = 0; i < objKeys.length; i++) {
Expand All @@ -195,7 +197,7 @@ function formatLabel(item, type, resources) {
label.push(formatter['fresnel:contentLast']);
}
} else {
label.push(value.map(replaceInnerDot).join(', '));
label.push(value.map(replaceInnerDot).join('\uE000 '));
}
} else {
label.push(replaceInnerDot(value));
Expand All @@ -204,8 +206,9 @@ function formatLabel(item, type, resources) {
}
let labelStr = label.join('');
// TODO: lots of punctuation for MARC going on inside some of these fields
labelStr = labelStr.replace(/([:.,]),/g, '$1');
labelStr = labelStr.replace(/\(,\s?/g, '(');
labelStr = labelStr.replace(/([:.\uE000])\uE000/g, '$1');
labelStr = labelStr.replace(/\(\uE000\s?/g, '(');
labelStr = labelStr.replace(/\uE000/g, ',');
return labelStr;
}

Expand Down

0 comments on commit 0827903

Please sign in to comment.