From 3cf456346662b8ee408f4f205254eb64b3e9b043 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 30 Aug 2022 17:18:55 +0800 Subject: [PATCH] Fix some parsing error for very old articles --- packages/text-to-speech/src/htmlToSsml.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/text-to-speech/src/htmlToSsml.ts b/packages/text-to-speech/src/htmlToSsml.ts index 17cf7a5c8..780a2887b 100644 --- a/packages/text-to-speech/src/htmlToSsml.ts +++ b/packages/text-to-speech/src/htmlToSsml.ts @@ -185,7 +185,7 @@ export const htmlToSsml = (html: string, options: SSMLOptions): SSMLItem[] => { console.log('creating ssml with options', options) const dom = parseHTML(html) - const body = dom.document.querySelector('#readability-content') + const body = dom.document.querySelector('#readability-page-1') if (!body) { throw new Error('Unable to parse HTML document') } @@ -204,9 +204,9 @@ export const htmlToSsml = (html: string, options: SSMLOptions): SSMLItem[] => { } const items: SSMLItem[] = [] - for (let i = 2; i < parsedNodes.length + 2; i++) { + for (let i = 1; i < parsedNodes.length + 1; i++) { const textItems: string[] = [] - const node = parsedNodes[i - 2] + const node = parsedNodes[i - 1] if (TOP_LEVEL_TAGS.includes(node.nodeName) || hasSignificantText(node)) { i = emitElement(textItems, node, true)