Fix thinkos with marked_up() rendering of bold/italic/underline.
authorCarl Hetherington <cth@carlh.net>
Sat, 2 Jul 2016 21:20:54 +0000 (22:20 +0100)
committerCarl Hetherington <cth@carlh.net>
Sat, 2 Jul 2016 21:20:54 +0000 (22:20 +0100)
ChangeLog
src/lib/render_subtitles.cc
test/render_subtitles_test.cc

index 32e881fec225efcee10846e1910829dfadac3e9f..ad696427307c9a56f41d648bd3d9acf92813560a 100644 (file)
--- 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.
index fea788a5cc1b8e833fd48a66847ead2971dacb25..782d06532e378d240699419c3031ae41fe04191a 100644 (file)
@@ -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) {
index c56f9dfa1aca54366ad088552b3a0fa7f61055ff..9ab4f5debd8bb7084ae6ee3de751886cc6825b9c 100644 (file)
@@ -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>");
+}