コード例 #1
0
    def test_char_count(self):  # {{{
        from calibre.srv.render_book import get_length
        from calibre.ebooks.oeb.parse_utils import html5_parse

        root = html5_parse('<p>a b\nc\td\re')
        self.ae(get_length(root), 5)
        root = html5_parse('<script>xyz</script>a<iMg>b')
        self.ae(get_length(root), 1002)
        root = html5_parse('<p><!-- abc -->m')
        self.ae(get_length(root), 1)
コード例 #2
0
 def t(html, body_children, nsmap=('http://www.w3.org/1999/xhtml', )):
     root = html5_parse(html)
     raw = html_as_json(root)
     # print(raw.decode('utf-8'))
     data = json.loads(raw)
     self.ae(data['version'], 1)
     self.ae(tuple(data['ns_map']), nsmap)
     bc = data['tree']['c'][1]['c']
     self.ae(bc, body_children)