lib/smpte_tt.js
function(captions) {
        var SMPTE_TT_BODY = '';
        //
        SMPTE_TT_BODY += SMPTE_TT.header.join('\n') + '\n';
        captions.forEach(function(caption) {
            if (caption.text.length > 0 && validateText(caption.text)) {
                if ((/&/.test(caption.text)) && (!(/&amp;/.test(caption.text)) || !(/&gt;/.test(caption.text)) || !(/&lt;/.test(caption.text)))) {
                    caption.text = caption.text.replace(/&/g, '&amp;');
                }
                if ((/</.test(caption.text)) && !(/&lt;/.test(caption.text))) {
                    caption.text = caption.text.replace(/</g, '&lt;');
                }
                if ((/>/.test(caption.text)) && !(/&gt;/.test(caption.text))) {
                    caption.text = caption.text.replace(/>/g, '&gt;');
                }
                SMPTE_TT_BODY += SMPTE_TT.lineTemplate.replace('{startTime}', module.exports.formatTime(caption.startTimeMicro))
                    .replace('{endTime}', module.exports.formatTime(caption.endTimeMicro))
                    .replace('{text}', module.exports.renderMacros(macros.fixItalics(macros.cleanMacros(caption.text)))) + '\n';
            }
        });

        return SMPTE_TT_BODY + SMPTE_TT.footer.join('\n') + '\n';
    }
function(captions) {
        var SMPTE_TT_BODY = '';
        //
        SMPTE_TT_BODY += SMPTE_TT.header.join('\n') + '\n';
        captions.forEach(function(caption) {
            if (caption.text.length > 0 && validateText(caption.text)) {
                if ((/&/.test(caption.text)) && (!(/&amp;/.test(caption.text)) || !(/&gt;/.test(caption.text)) || !(/&lt;/.test(caption.text)))) {
                    caption.text = caption.text.replace(/&/g, '&amp;');
                }
                if ((/</.test(caption.text)) && !(/&lt;/.test(caption.text))) {
                    caption.text = caption.text.replace(/</g, '&lt;');
                }
                if ((/>/.test(caption.text)) && !(/&gt;/.test(caption.text))) {
                    caption.text = caption.text.replace(/>/g, '&gt;');
                }
                SMPTE_TT_BODY += SMPTE_TT.lineTemplate.replace('{startTime}', module.exports.formatTime(caption.startTimeMicro))
                    .replace('{endTime}', module.exports.formatTime(caption.endTimeMicro))
                    .replace('{text}', module.exports.renderMacros(macros.fixItalics(macros.cleanMacros(caption.text)))) + '\n';
            }
        });

        return SMPTE_TT_BODY + SMPTE_TT.footer.join('\n') + '\n';
    }
function ( captions ) { var SMPTE_TT_BODY = '' ; // SMPTE_TT_BODY += SMPTE_TT . header . join ( '\n' ) + '\n' ; captions . forEach ( function ( caption ) { if ( caption . text . length > 0 && validateText ( caption . text ) ) { if ( ( / & / . test ( caption . text ) ) && ( ! ( / &amp; / . test ( caption . text ) ) || ! ( / &gt; / . test ( caption . text ) ) || ! ( / &lt; / . test ( caption . text ) ) ) ) { caption . text = caption . text . replace ( / & / g , '&amp;' ) ; } if ( ( / < / . test ( caption . text ) ) && ! ( / &lt; / . test ( caption . text ) ) ) { caption . text = caption . text . replace ( / < / g , '&lt;' ) ; } if ( ( / > / . test ( caption . text ) ) && ! ( / &gt; / . test ( caption . text ) ) ) { caption . text = caption . text . replace ( / > / g , '&gt;' ) ; } SMPTE_TT_BODY += SMPTE_TT . lineTemplate . replace ( '{startTime}' , module . exports . formatTime ( caption . startTimeMicro ) ) . replace ( '{endTime}' , module . exports . formatTime ( caption . endTimeMicro ) ) . replace ( '{text}' , module . exports . renderMacros ( macros . fixItalics ( macros . cleanMacros ( caption . text ) ) ) ) + '\n' ; } } ) ; return SMPTE_TT_BODY + SMPTE_TT . footer . join ( '\n' ) + '\n' ; }
Generate SAMI captions from JSON
@function
@param {array} captions - File to read
@public
Generate SAMI captions from JSON