@acrossthecloud/speakhtml
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -14,3 +14,3 @@ "use strict"; | ||
const fs = require("fs"); | ||
const handleElem = (s) => { | ||
const handleElem = (s, filter) => { | ||
if (!s.tagName) { | ||
@@ -24,2 +24,5 @@ if (s.nodeType !== s.COMMENT_NODE) { | ||
} | ||
if (filter && filter(s)) { | ||
return ''; | ||
} | ||
if (['video', 'audio', 'iframe'].includes(s.tagName.toLowerCase())) { | ||
@@ -53,3 +56,3 @@ return ''; | ||
return headerTags[s.tagName.toLowerCase()] + (s.hasChildNodes ? Array.from(s.childNodes).reduce((acc, node) => { | ||
return acc + handleElem(node); | ||
return acc + handleElem(node, filter); | ||
}, '') : '') + '</emphasis>'; | ||
@@ -71,3 +74,3 @@ } | ||
return ssmlTagName + (s.hasChildNodes ? Array.from(s.childNodes).reduce((acc, node) => { | ||
return acc + handleElem(node); | ||
return acc + handleElem(node, filter); | ||
}, '') : '') + (ssmlTagName ? ssmlTagName.replace('<', '</') : ''); | ||
@@ -88,8 +91,8 @@ }; | ||
} | ||
const fromHTML = (s, enclosed = true) => { | ||
return (enclosed ? '<speak>' : '') + handleElem((new jsdom_1.JSDOM(s)).window.document.body).replace(/\s\s+/g, ' ') + (enclosed ? '</speak>' : ''); | ||
const fromHTML = (s, enclosed = true, filter) => { | ||
return (enclosed ? '<speak>' : '') + handleElem((new jsdom_1.JSDOM(s)).window.document.body, filter).replace(/\s\s+/g, ' ') + (enclosed ? '</speak>' : ''); | ||
}; | ||
const fromURL = (u, enclosed = true) => __awaiter(void 0, void 0, void 0, function* () { | ||
const fromURL = (u, enclosed = true, filter) => __awaiter(void 0, void 0, void 0, function* () { | ||
let dom = yield jsdom_1.JSDOM.fromURL(u.toString()); | ||
return (enclosed ? '<speak>' : '') + handleElem(dom.window.document.body).replace(/\s\s+/g, ' ') + (enclosed ? '</speak>' : ''); | ||
return (enclosed ? '<speak>' : '') + handleElem(dom.window.document.body, filter).replace(/\s\s+/g, ' ') + (enclosed ? '</speak>' : ''); | ||
}); | ||
@@ -96,0 +99,0 @@ module.exports = { |
{ | ||
"name": "@acrossthecloud/speakhtml", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "for converting html to ssml", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43200
97