Merge pull request #1243 from omnivore-app/fix/ssml-to-speech-idx

Start at index 3, because the frontend starts two nodes above the backend
This commit is contained in:
Hongbo Wu 2022-09-26 19:13:49 +08:00 committed by GitHub
commit 1671d62c14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -228,9 +228,9 @@ export const htmlToSsmlItems = (
}
const items: SSMLItem[] = []
for (let i = 2; i < parsedNodes.length + 2; i++) {
for (let i = 3; i < parsedNodes.length + 3; i++) {
const textItems: string[] = []
const node = parsedNodes[i - 2]
const node = parsedNodes[i - 3]
if (TOP_LEVEL_TAGS.includes(node.nodeName) || hasSignificantText(node)) {
const idx = i
@ -342,10 +342,10 @@ export const htmlToSpeechFile = (htmlInput: HtmlInput): SpeechFile => {
wordOffset += titleUtterance.wordCount
}
// start at 2 to skip the #readability-content and #readability-page-1 elements
for (let i = 2; i < parsedNodes.length + 2; i++) {
// start at 3 to skip the #readability-content and #readability-page-1 elements
for (let i = 3; i < parsedNodes.length + 3; i++) {
const textItems: string[] = []
const node = parsedNodes[i - 2]
const node = parsedNodes[i - 3]
if (TOP_LEVEL_TAGS.includes(node.nodeName) || hasSignificantText(node)) {
// use paragraph as anchor