fix: remove html tags

This commit is contained in:
Maria Schreiber
2017-11-24 10:29:06 -05:00
parent 2e77d7f497
commit 5152a6bf5f
3 changed files with 5499 additions and 5 deletions

View File

@@ -3,6 +3,7 @@
import he from 'he';
import axios from 'axios';
import { find } from 'lodash';
import striptags from 'striptags';
export async function getSubtitles({
videoID,
@@ -46,14 +47,14 @@ export async function getSubtitles({
const [, start] = startRegex.exec(line);
const [, dur] = durRegex.exec(line);
const fontTag = new RegExp('<'+'font'+'[^><]*>|<.'+'font'+'[^><]*>','g');
const htmlText = line
.replace(/<text.+>/, '')
.replace(/&amp;/gi, '&')
.replace(/<\/?[^>]+(>|$)/g, '')
.replace(fontTag, '');
.replace(/<\/?[^>]+(>|$)/g, '');
const text = he.decode(htmlText);
const strippedText = striptags(htmlText);
const text = he.decode(strippedText);
return { start, dur, text };
});