Skip to content

Commit

Permalink
apply same normalization to authority from authority attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
nleanba committed Sep 27, 2024
1 parent 4a45ad6 commit 518e3a2
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/gg2rdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,28 @@ export function gg2rdf(
} else if (authority) {
fullAuthority = authority;
} else if (cTaxon.getAttribute("authority")) {
fullAuthority = normalizeAuthority(cTaxon.getAttribute("authority"));
let authority: string = cTaxon.getAttribute("authority") ?? "";
if (authority) {
authority = substringBefore(authority, " in ");
if (authority === "L.") authority = "Linnaeus";
if (authority.length >= 2 && !/[a-z]/.test(authority)) {
authority = authority.replaceAll(
/\w[A-Z]+\b[^.]|\w[A-Z]+$/g,
(s) => s[0] + s.slice(1).toLowerCase(),
);
}

if (cTaxon.hasAttribute("authorityYear")) {
authority += ", " + cTaxon.getAttribute("authorityYear");
} else if (allow_defining && !/[0-9]/.test(authority)) {
// if this treatment defines this taxon and the authority given contains no year / numbers, infer from docDate
warnings.push(`Using document metadata for authority year`);
authority += ", " + doc.getAttribute("docDate");
}

authority = normalizeAuthority(authority);
}
fullAuthority = authority;
} else if (allow_defining) {
// if taxon is the treated taxon and no explicit authority info is given on the element, fall back to document info
let docAuthor = normalizeSpace(doc.getAttribute("docAuthor"))
Expand Down

0 comments on commit 518e3a2

Please sign in to comment.