File indexing completed on 2024-06-23 04:52:41

0001 /*
0002         SPDX-FileCopyrightText: 2007-2009 Sergio Pistone <sergio_pistone@yahoo.com.ar>
0003         SPDX-FileCopyrightText: 2021-2023 Mladen Milinkovic <maxrd2@smoothware.net>
0004 
0005         SPDX-License-Identifier: GPL-2.0-or-later
0006 
0007         @name Remove Hearing Impaired Text
0008         @version 1.0
0009         @summary Remove hearing impaired text from subtitle lines.
0010         @author SubtitleComposer Team
0011 */
0012 
0013 const s = subtitle.instance();
0014 for(let i = s.linesCount() - 1; i >= 0; i--) {
0015         let line = s.line(i),
0016                 text = line.richPrimaryText()
0017                         .replace(/\s*\([^)]+\)\s*/g, ' ')
0018                         .replace(/\s*\[[^\]]+\]\s*/g, ' ')
0019                         .replace(/^(<.*>)?.*:\s+/gm, '$1')
0020                         .replace(/(^\s*|\s*$)/gm, '');
0021 
0022         if(text.replace(/(<[^>]+>|\s)/g, '') === '')
0023                 s.removeLine(i);
0024         else
0025                 line.setRichPrimaryText(text);
0026 }