diff --git a/pycaption/dfxp/base.py b/pycaption/dfxp/base.py index e1045715..a8ab7cc2 100644 --- a/pycaption/dfxp/base.py +++ b/pycaption/dfxp/base.py @@ -109,11 +109,8 @@ def _translate_p_tag(self, p_tag): self._translate_tag(p_tag) styles = self._translate_style(p_tag) - if len(self.nodes) > 0: - return Caption( - start, end, self.nodes, style=styles, - layout_info=p_tag.layout_info) - return None + return Caption( + start, end, self.nodes, style=styles, layout_info=p_tag.layout_info) def _find_times(self, p_tag): start = self._translate_time(p_tag['begin']) @@ -183,6 +180,10 @@ def _translate_tag(self, tag): elif tag.name == 'span': # convert span self._translate_span(tag) + elif tag.name == 'p' and not tag.contents: + node = CaptionNode.create_text( + '', layout_info=tag.layout_info) + self.nodes.append(node) else: # recursively call function for any children elements for a in tag.contents: diff --git a/tests/test_dfxp.py b/tests/test_dfxp.py index 131b73a0..62967801 100644 --- a/tests/test_dfxp.py +++ b/tests/test_dfxp.py @@ -117,27 +117,6 @@ def test_empty_paragraph(self): except CaptionReadError: self.fail("Failing on empty paragraph") - def test_empty_cue(self): - caption_set = DFXPReader().read( - SAMPLE_DFXP_EMPTY_CUE) - caps = caption_set.get_captions('en-US') - self.assertEquals(caps[1], []) - -SAMPLE_DFXP_EMPTY_CUE = """\ - - - - - - - - -
-

abc

-

-
- -
""" SAMPLE_DFXP_INVALID_POSITIONING_VALUE_TEMPLATE = """\