}
+static
+string
+escape_text (string text)
+{
+ /* We must escape some things, otherwise they might confuse our subtitle
+ renderer (which uses entities and some HTML-esque markup to do bold/italic etc.)
+ */
+ boost::algorithm::replace_all(text, "&", "&");
+ boost::algorithm::replace_all(text, "<", "<");
+ boost::algorithm::replace_all(text, ">", ">");
+ return text;
+}
+
+
void
TextDecoder::emit_plain_start (ContentTime from, vector<dcp::SubtitleString> subtitles)
{
for (auto& subtitle: subtitles) {
- /* We must escape some things, otherwise they might confuse our subtitle
- renderer (which uses entities and some HTML-esque markup to do bold/italic etc.)
- */
- string text = subtitle.text();
- boost::algorithm::replace_all(text, "&", "&");
- boost::algorithm::replace_all(text, "<", "<");
- boost::algorithm::replace_all(text, ">", ">");
- subtitle.set_text (text);
+ subtitle.set_text(escape_text(subtitle.text()));
/* Set any forced appearance */
if (content()->colour()) {