From 9455ebf88be4f4afbd32455db334a44af588553e Mon Sep 17 00:00:00 2001 From: Zeping Lee Date: Sat, 23 Nov 2024 15:37:51 +0800 Subject: [PATCH] Fix missing citation format --- lib/utils/citeproc.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/utils/citeproc.ts b/lib/utils/citeproc.ts index b527d0eb..f38780bb 100644 --- a/lib/utils/citeproc.ts +++ b/lib/utils/citeproc.ts @@ -214,17 +214,22 @@ export function getRefTemplate(cslXml: CslXml) { } export function getField(cslXml: CslXml) { - return cslXml - .getNodesByName(cslXml.dataObj, "category") - .filter((node) => "field" in node.attrs)[0]?.attrs["field"]; + return ( + cslXml + .getNodesByName(cslXml.dataObj, "category") + .filter((node) => "field" in node.attrs)[0]?.attrs["field"] ?? + "generic-base" + ); } export function getCitationFormat(cslXml: CslXml) { - return cslXml - .getNodesByName(cslXml.dataObj, "category") - .filter((node) => "citation-format" in node.attrs)[0]?.attrs[ - "citation-format" - ]; + return ( + cslXml + .getNodesByName(cslXml.dataObj, "category") + .filter((node) => "citation-format" in node.attrs)[0]?.attrs[ + "citation-format" + ] ?? "numeric" + ); } export function getSummary(cslXml: CslXml): string {