react-text-to-speech
Advanced tools
Comparing version 0.14.2 to 0.14.3
@@ -25,3 +25,3 @@ import React, { cloneElement, isValidElement, useEffect, useMemo, useRef, useState } from "react"; | ||
return; | ||
const utterance = new SpeechSynthesisUtterance(sanitize(ArrayToText(words))); | ||
const utterance = new SpeechSynthesisUtterance(sanitize(ArrayToText(words), highlightText)); | ||
utterance.pitch = pitch; | ||
@@ -28,0 +28,0 @@ utterance.rate = rate; |
@@ -53,2 +53,3 @@ import { DetailedHTMLProps, HTMLAttributes, ReactNode } from "react"; | ||
export type Index = string | number; | ||
export type Replacer = (match: string) => string; | ||
export type StringArray = string | StringArray[]; |
@@ -9,2 +9,2 @@ import { ReactNode } from "react"; | ||
export declare function isParent(parentIndex: string, index?: string): boolean; | ||
export declare const sanitize: (text: string) => string; | ||
export declare function sanitize(text: string, strict: boolean): string; |
@@ -53,2 +53,8 @@ import { isValidElement } from "react"; | ||
} | ||
export const sanitize = (text) => text.replace(/<([^>]+)>|;/g, (_, group) => (group ? `(${group})` : "(")); | ||
export function sanitize(text, strict) { | ||
if (strict) | ||
var replacer = (match) => (match === "<" ? "(" : ")"); | ||
else | ||
replacer = (match) => (match === "<" ? "less than" : match === ">" ? "greater than" : ")"); | ||
return text.replace(/[<>;]/g, replacer); | ||
} |
{ | ||
"name": "react-text-to-speech", | ||
"version": "0.14.2", | ||
"version": "0.14.3", | ||
"description": "An easy to use react component for the Web Speech API.", | ||
@@ -25,2 +25,4 @@ "type": "module", | ||
"tts-react", | ||
"speak", | ||
"say", | ||
"highlight", | ||
@@ -27,0 +29,0 @@ "queue", |
38208
419