summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-07-02 22:20:54 +0100
committerCarl Hetherington <cth@carlh.net>2016-07-02 22:20:54 +0100
commit59f07d959514b80fcce5aa99f575ef8e6fceba8b (patch)
treecb99bbe0c8fe9241c20a378085b03a6a046773ab
parent066e772c9ef7e6d08326a04a351514374e3d40e7 (diff)
Fix thinkos with marked_up() rendering of bold/italic/underline.
-rw-r--r--ChangeLog2
-rw-r--r--src/lib/render_subtitles.cc6
-rw-r--r--test/render_subtitles_test.cc19
3 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 32e881fec..ad6964273 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2016-07-02 Carl Hetherington <cth@carlh.net>
+ * Fix problems with markup in subrip/SSA/ASS.
+
* Updated ru_RU translation from Igor Voytovich.
* Updated uk_UA translation from Igor Voytovich.
diff --git a/src/lib/render_subtitles.cc b/src/lib/render_subtitles.cc
index fea788a5c..782d06532 100644
--- a/src/lib/render_subtitles.cc
+++ b/src/lib/render_subtitles.cc
@@ -52,6 +52,7 @@ marked_up (list<dcp::SubtitleString> subtitles)
bool bold = false;
bool underline = false;
BOOST_FOREACH (dcp::SubtitleString const & i, subtitles) {
+
if (i.italic() && !italic) {
out += "<i>";
}
@@ -61,9 +62,6 @@ marked_up (list<dcp::SubtitleString> subtitles)
if (i.underline() && !underline) {
out += "<u>";
}
-
- out += i.text ();
-
if (!i.underline() && underline) {
out += "</u>";
}
@@ -77,6 +75,8 @@ marked_up (list<dcp::SubtitleString> subtitles)
italic = i.italic ();
bold = i.bold ();
underline = i.underline ();
+
+ out += i.text ();
}
if (underline) {
diff --git a/test/render_subtitles_test.cc b/test/render_subtitles_test.cc
index c56f9dfa1..9ab4f5deb 100644
--- a/test/render_subtitles_test.cc
+++ b/test/render_subtitles_test.cc
@@ -82,3 +82,22 @@ BOOST_AUTO_TEST_CASE (render_markup_test4)
add (s, "Hello", true, true, true);
BOOST_CHECK_EQUAL (marked_up (s), "<i><b><u>Hello</u></b></i>");
}
+
+/** Test marked_up() in render_subtitles.cc */
+BOOST_AUTO_TEST_CASE (render_markup_test5)
+{
+ std::list<dcp::SubtitleString> s;
+ add (s, "Hello", false, true, false);
+ add (s, " world.", false, false, false);
+ BOOST_CHECK_EQUAL (marked_up (s), "<b>Hello</b> world.");
+}
+
+/** Test marked_up() in render_subtitles.cc */
+BOOST_AUTO_TEST_CASE (render_markup_test6)
+{
+ std::list<dcp::SubtitleString> s;
+ add (s, "Hello", true, false, false);
+ add (s, " world ", false, false, false);
+ add (s, "we are bold.", false, true, false);
+ BOOST_CHECK_EQUAL (marked_up (s), "<i>Hello</i> world <b>we are bold.</b>");
+}