npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ttml

v0.1.0

Published

A simple library to read/write TTML

Downloads

82

Readme

NPM Build Status XO code style

ttml-parser

A simple library to read/write TTML

For example, it converts the following JS object:

{
  title: 'Timed Text TTML Example',
  copyright: 'The Authors (c) 2006',
  languages: {
    en: {
      lines: [
        {
          start: '0.76s',
          end: '3.45s',
          text: 'It seems a paradox, does it not,'
        },
        {
          start: '5.0s',
          end: '10.0s',
          text: 'that the image formed on<br/>the Retina should be inverted?'
        },
        {
          start: '10.0s',
          end: '16.0s',
          text: 'It is puzzling, why is it<br/>we do not see things upside-down?'
        }
      ]
    },
    es: {
      lines: [
        {
          start: '0.76s',
          end: '3.45s',
          text: 'Parece una paradoja, no es así,'
        },
        {
          start: '5.0s',
          end: '10.0s',
          text: 'que la imagen formada en<br/>la Retina se invierta.'
        },
        {
          start: '10.0s',
          end: '16.0s',
          text: 'Es desconcertante, ¿por qué<br/>no vemos las cosas al revés?'
        }
      ]
    }
  }
}

into the following XML text:

<?xml version="1.0" encoding="UTF-8"?>
<tt xml:lang="en" xmlns="http://www.w3.org/ns/ttml">
  <head>
    <metadata xmlns:ttm="http://www.w3.org/ns/ttml#metadata">
      <ttm:title>Timed Text TTML Example</ttm:title>
      <ttm:copyright>The Authors (c) 2006</ttm:copyright>
    </metadata>
  </head>
  <body>
    <div xml:lang="en">
      <p begin="0.76s" end="3.45s">It seems a paradox, does it not,</p>
      <p begin="5.0s" end="10.0s">that the image formed on&lt;br/&gt;the Retina should be inverted?</p>
      <p begin="10.0s" end="16.0s">It is puzzling, why is it&lt;br/&gt;we do not see things upside-down?</p>
    </div>
    <div xml:lang="es">
      <p begin="0.76s" end="3.45s">Parece una paradoja, no es así,</p>
      <p begin="5.0s" end="10.0s">que la imagen formada en&lt;br/&gt;la Retina se invierta.</p>
      <p begin="10.0s" end="16.0s">Es desconcertante, ¿por qué&lt;br/&gt;no vemos las cosas al revés?</p>
    </div>
  </body>
</tt>

and vice versa.

Install

NPM

Usage

const TTML = require('ttml');
const ttmlStr = 'Above XML text';
const obj = TTML.parse(ttmlStr);
const str = TTML.stringify(obj);
str === ttmlStr; // true