NAME

Whatpm::WebVTT::Serializer - A WebVTT serializer


SYNOPSIS

  use Whatpm::WebVTT::Serializer;
  
  $string = Whatpm::WebVTT::Serializer
      ->track_to_char_string ($track);
  
  $text = Whatpm::WebVTT::Serializer->dom_to_text
      ($document_fragment)


DESCRIPTION

The Whatpm::WebVTT::Serializer module provides methods to convert in-memory representation of WebVTT into strings in the WebVTT format.


METHODS

$string = Whatpm::WebVTT::Serializer->track_to_char_string ($track)

Serialize the specified track object (DOM TextTrack, the Message::DOM::TextTrack manpage into WebVTT format. The serializer does its best effort to output a valid WebVTT file, while keeping original semantics as far as possible. Please note that some TextTrack object cannot serialize as is. For example, the TextTrack object containing a cue with ID --> cannot represent in WebVTT, such that the serializer replace it by -->.

The output of this method is a character string, i.e. a possibly utf8-flagged string of characters, not bytes.

$text = Whatpm::WebVTT::Serializer->dom_to_text ($node)

Serialize the specified DOM node into WebVTT cue text format. The specified node is expected to have structure that could be generated by the WebVTT's DOM construction rule (or the Whatpm::WebVTT::Parser manpage's text_to_dom method), otherwise no meaningful result would be returned.

The output of this method is a character string. It is expected to be used to set the new value of the $cue->text attribute.


SEE ALSO

WebVTT Standard <http://dev.w3.org/html5/webvtt/>.

the Whatpm::WebVTT::Parser manpage.

the Message::DOM::TextTrack manpage.


AUTHOR

Wakaba <w@suika.fam.cx>.


LICENSE

Copyright 2012 Wakaba <w@suika.fam.cx>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.