diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-01-16 10:07:44 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-01-16 10:07:44 +0000 |
| commit | 6a90762b8d103d256aa3851e55574154881a4612 (patch) | |
| tree | 612ded24485c94b2a10731b8b97d8e11de8ee70f /src/dcp_reader.cc | |
| parent | 7f8e3b9bb174935885acb40dffc12305c87fcfdd (diff) | |
Hack; cope with libdcp's new idea of encoding italic with <i> markup.
Diffstat (limited to 'src/dcp_reader.cc')
| -rw-r--r-- | src/dcp_reader.cc | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/dcp_reader.cc b/src/dcp_reader.cc index 73a2276..3376e36 100644 --- a/src/dcp_reader.cc +++ b/src/dcp_reader.cc @@ -25,6 +25,7 @@ using std::list; using std::cout; +using std::string; using boost::shared_ptr; using namespace sub; @@ -84,8 +85,36 @@ DCPReader::DCPReader (boost::filesystem::path file) sub.effect_colour = dcp_to_colour ((*i)->effect_color ()); sub.colour = dcp_to_colour ((*i)->color ()); - sub.italic = (*i)->italic (); - - _subs.push_back (sub); + + /* Hack upon hack upon hack: detokenise <i> ... </i> */ + + string original = sub.text; + sub.text.clear (); + size_t i = 0; + while (i < original.length()) { + size_t const left = original.length() - i; + if (left >= 3 && original.substr(i, 3) == "<i>") { + if (!sub.text.empty ()) { + _subs.push_back (sub); + sub.text.clear (); + } + sub.italic = true; + i += 3; + } else if (left >= 4 && original.substr(i, 4) == "</i>") { + if (!sub.text.empty ()) { + _subs.push_back (sub); + sub.text.clear (); + } + sub.italic = false; + i += 4; + } else { + sub.text += original[i]; + ++i; + } + } + + if (!sub.text.empty ()) { + _subs.push_back (sub); + } } } |
