def test_get_markers_and_text_emph(self):
        text = '(A) aaaa. (<E T="03">1</E>) 1111'
        xml = etree.fromstring('<P>%s</P>' % text)
        markers = reg_text.get_markers(text)
        result = reg_text.get_markers_and_text(xml, markers)

        a, a1 = result
        self.assertEqual(('A', ('(A) aaaa. ', '(A) aaaa. ')), a)
        self.assertEqual(('<E T="03">1</E>', ('(1) 1111',
                                              '(<E T="03">1</E>) 1111')), a1)
    def test_get_markers_and_text_deceptive_single(self):
        """Don't treat a single marker differently than multiple, there might
        be prefix text"""
        node = etree.fromstring('<P>Words then (a) a subparagraph</P>')
        results = reg_text.get_markers_and_text(node, ['a'])
        self.assertEqual(len(results), 2)
        prefix, subpar = results

        self.assertEqual(prefix[0], mtypes.MARKERLESS)
        self.assertEqual(prefix[1][0], 'Words then ')
        self.assertEqual(subpar[0], 'a')
        self.assertEqual(subpar[1][0], '(a) a subparagraph')
    def test_get_markers_and_text(self):
        text = u'(a) <E T="03">Transfer </E>—(1) <E T="03">Notice.</E> follow'
        wrap = '<P>%s</P>' % text

        doc = etree.fromstring(wrap)
        markers = reg_text.get_markers(text)
        result = reg_text.get_markers_and_text(doc, markers)

        markers = [r[0] for r in result]
        self.assertEqual(markers, [u'a', u'1'])

        text = [r[1][0] for r in result]
        self.assertEqual(text, [u'(a) Transfer —', u'(1) Notice. follow'])

        tagged = [r[1][1] for r in result]
        self.assertEqual(
            tagged,
            [u'(a) <E T="03">Transfer </E>—',
             u'(1) <E T="03">Notice.</E> follow'])