From 3fe5df8661f8527b4dc2e5e3470940c1ead362c1 Mon Sep 17 00:00:00 2001 From: Aferdita Muriqi Date: Sat, 12 Aug 2023 09:25:20 -0400 Subject: [PATCH] ALA citation format fixes --- package-lock.json | 4 +- package.json | 2 +- src/modules/citation/CitationModule.ts | 61 +++++++++++++------------- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index 19f5d60b..3c63322e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@d-i-t-a/reader", - "version": "2.3.10", + "version": "2.3.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@d-i-t-a/reader", - "version": "2.3.10", + "version": "2.3.11", "license": "Apache-2.0", "dependencies": { "@types/pdfjs-dist": "^2.7.4", diff --git a/package.json b/package.json index e9cb39c9..d8622230 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@d-i-t-a/reader", - "version": "2.3.10", + "version": "2.3.11", "description": "A viewer application for EPUB files.", "repository": "https://github.com/d-i-t-a/R2D2BC", "license": "Apache-2.0", diff --git a/src/modules/citation/CitationModule.ts b/src/modules/citation/CitationModule.ts index a83e8627..f8078c36 100644 --- a/src/modules/citation/CitationModule.ts +++ b/src/modules/citation/CitationModule.ts @@ -210,24 +210,21 @@ export default class CitationModule implements ReaderModule { let mlaString = ""; let apaString = ""; if (self.properties.publisher) { - mlaString = mlaString + self.properties.publisher + ", "; - chicagoString = chicagoString + self.properties.publisher + ", "; + mlaString = mlaString + self.properties.publisher; + chicagoString = chicagoString + self.properties.publisher; } else if ( self.publication.Metadata.Publisher && self.publication.Metadata.Publisher[0].Name ) { - mlaString = - mlaString + self.publication.Metadata.Publisher[0].Name + ", "; + mlaString = mlaString + self.publication.Metadata.Publisher[0].Name; chicagoString = - chicagoString + - self.publication.Metadata.Publisher[0].Name + - ", "; + chicagoString + self.publication.Metadata.Publisher[0].Name; } if (self.properties.published) { apaString = apaString + "(" + self.properties.published + ")"; - mlaString = mlaString + self.properties.published; - chicagoString = chicagoString + self.properties.published; + mlaString = mlaString + ", " + self.properties.published; + chicagoString = chicagoString + ", " + self.properties.published; } else if (self.publication.Metadata.PublicationDate) { if (self.publication.Metadata.PublicationDate.getFullYear() > 0) { apaString = @@ -237,9 +234,11 @@ export default class CitationModule implements ReaderModule { ")"; mlaString = mlaString + + ", " + self.publication.Metadata.PublicationDate.getFullYear(); chicagoString = chicagoString + + ", " + self.publication.Metadata.PublicationDate.getFullYear(); } } @@ -256,15 +255,15 @@ export default class CitationModule implements ReaderModule { let bookTitleFormatted = function () { if (self.properties.title) { return [ - self.properties.title + ". ", - self.properties.title + ". ", - self.properties.title + ". ", + "" + self.properties.title + ". ", + "" + self.properties.title + ". ", + "" + self.properties.title + ". ", ]; } else if (self.publication.Metadata.Title) { return [ - self.publication.Metadata.Title + ". ", - self.publication.Metadata.Title + ". ", - self.publication.Metadata.Title + ". ", + "" + self.publication.Metadata.Title + ". ", + "" + self.publication.Metadata.Title + ". ", + "" + self.publication.Metadata.Title + ". ", ]; } else { return ["", "", ""]; @@ -312,7 +311,7 @@ export default class CitationModule implements ReaderModule { if (self.properties.publisher) { mlaString = mlaString + self.properties.publisher + ", "; chicagoString = chicagoString + self.properties.publisher + ", "; - apaString = apaString + self.properties.publisher + ", "; + apaString = apaString + self.properties.publisher; } else if ( self.publication.Metadata.Publisher && self.publication.Metadata.Publisher[0].Name @@ -323,8 +322,7 @@ export default class CitationModule implements ReaderModule { chicagoString + self.publication.Metadata.Publisher[0].Name + ", "; - apaString = - apaString + self.publication.Metadata.Publisher[0].Name + ", "; + apaString = apaString + self.publication.Metadata.Publisher[0].Name; } if ( @@ -438,44 +436,47 @@ export default class CitationModule implements ReaderModule { selectedText(selection, self.properties.characters) + "“" + "

" + - "" + - chicago + - ""; + chicago; const citationApa = "“" + selectedText(selection, self.properties.characters) + "“" + "

" + - "" + - apa + - ""; + apa; const citationMla = "“" + selectedText(selection, self.properties.characters) + "“" + "

" + - "" + - mla + - ""; + mla; let citation = ""; if ( self.properties.styles?.includes(CitationStyle[CitationStyle.Chicago]) ) { - citation = citation + "Chicago:
" + citationChicago + "

"; + if (self.properties.styles.length > 1) { + citation = citation + "Chicago:
"; + } + citation = citation + citationChicago + "

"; } if ( self.properties.styles?.includes(CitationStyle[CitationStyle.APA]) ) { - citation = citation + "APA:
" + citationApa + "

"; + if (self.properties.styles.length > 1) { + citation = citation + "APA:
"; + } + citation = citation + citationApa + "

"; } if ( self.properties.styles?.includes(CitationStyle[CitationStyle.MLA]) ) { - citation = citation + "MLA:
" + citationMla + "

"; + if (self.properties.styles.length > 1) { + citation = citation + "MLA:
"; + } + citation = citation + citationMla + "

"; } self.copyToClipboard(citation);