Skip to content

Commit

Permalink
trim text, need to find a better solution for whitespaces between opt…
Browse files Browse the repository at this point in the history
…ions etc.
  • Loading branch information
aferditamuriqi committed Sep 20, 2020
1 parent 2c76942 commit ef02260
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/modules/TTS/splitting.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function createElement(parent, key, text, whitespace) {
var el = root.createElement('span');
// key;// && (el.className = "orange");
if (text) {
if (!whitespace) {
if (!whitespace) {
if (text.replace(/[^a-zA-Z0-9 ]/g, "").length > 0) {
el.setAttribute("data-" + key, text.replace(/[^a-zA-Z0-9 ]/g, ""));
} else {
Expand All @@ -44,7 +44,7 @@ function createElement(parent, key, text, whitespace) {
} else {
el.setAttribute("data-" + key, "");
}
el.textContent = text;
el.textContent = text;
}
return (parent && appendChild(parent, el)) || el;
}
Expand Down Expand Up @@ -230,7 +230,8 @@ function splitText(el, key, splitOn, includePrevious, preserveWhitespace) {
// Get the text to split, trimming out the whitespace
/** @type {string} */
var wholeText = next.wholeText || '';
var contents = wholeText;
var contents = wholeText.trim();
// var contents = wholeText;

// If there's no text left after trimming whitespace, continue the loop
if (contents.length) {
Expand Down

0 comments on commit ef02260

Please sign in to comment.