From 8f4732771cf98b9a6bc4ab63459ac858f4c1ae27 Mon Sep 17 00:00:00 2001 From: davivcu Date: Sat, 25 May 2024 23:44:06 +0200 Subject: [PATCH] Quick fix for pb fix on issue 228, improve syntax in an analogue parser's utility function --- src/app/services/xml-parsers/analogue-parser.ts | 7 ++++++- .../xml-parsers/structure-xml-parser.service.ts | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/app/services/xml-parsers/analogue-parser.ts b/src/app/services/xml-parsers/analogue-parser.ts index e99ba434c..443353dbc 100644 --- a/src/app/services/xml-parsers/analogue-parser.ts +++ b/src/app/services/xml-parsers/analogue-parser.ts @@ -123,9 +123,14 @@ export class AnalogueParser extends BasicParser implements Parser { } private getQuotedTextFromElements(sources: BibliographicEntry[], elements: XMLElement[]): [{id: string, quote: string}] { + // eslint-disable-next-line prefer-const let quotesInSources = this.getQuotedTextFromSources(sources); const notDisplayedInText = ['Note','BibliographicList','BibliographicEntry','BibliographicStructEntry','Analogue','MsDesc']; - elements.forEach((el: XMLElement) => { if (!notDisplayedInText.includes(el['type'])) { quotesInSources.push( { id: el.id, quote: el })} }); + elements.forEach((el: XMLElement) => { + if (!notDisplayedInText.includes(el['type'])) { + quotesInSources.push( { id: el.id, quote: el }) + } + }); return quotesInSources; } diff --git a/src/app/services/xml-parsers/structure-xml-parser.service.ts b/src/app/services/xml-parsers/structure-xml-parser.service.ts index 89dbe3ce1..63b4bc151 100644 --- a/src/app/services/xml-parsers/structure-xml-parser.service.ts +++ b/src/app/services/xml-parsers/structure-xml-parser.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { AppConfig } from '../../app.config'; import { EditionStructure, GenericElement, OriginalEncodingNodeType, Page, XMLElement } from '../../models/evt-models'; -import { createNsResolver, getElementsBetweenTreeNode, isNestedInElem } from '../../utils/dom-utils'; +import { getElementsBetweenTreeNode, isNestedInElem } from '../../utils/dom-utils'; import { GenericParserService } from './generic-parser.service'; import { getID, ParseResult } from './parser-models'; @@ -99,7 +99,12 @@ export class StructureXmlParserService { return pageContent .map((node) => { - const origEl = getEditionOrigNode(node, doc); + //const origEl = getEditionOrigNode(node, doc); + // issue #228 + // the original line is commented because this function causes the node to be revered at its original state + // before the pb division, see issue #228 details for further info. + // for now this quick fix allows a proper text division but we need to investigate exceptions and particular cases + const origEl = node; if (origEl.nodeName === this.frontTagName || isNestedInElem(origEl, this.frontTagName)) { if (this.hasOriginalContent(origEl)) { @@ -135,6 +140,7 @@ export class StructureXmlParserService { } } +/* this function is only momentarily commented, waiting for issue #228 to be better addressed function getEditionOrigNode(el: XMLElement, doc: Document) { if (el.getAttribute && el.getAttribute('xpath')) { const path = doc.documentElement.namespaceURI ? el.getAttribute('xpath').replace(/\//g, '/ns:') : el.getAttribute('xpath'); @@ -145,3 +151,4 @@ function getEditionOrigNode(el: XMLElement, doc: Document) { return el; } +*/