Example #1
0
    def render_styles(self, text_node):
        node = text_node
        if not self.is_empty():
            # Nest the tags.
            for s in sorted(self.styles, reverse=True):
                opt = Options.for_style(self.style_map, s)
                node = DOM.create_element(opt.element, opt.props, node)

        return node
Example #2
0
    def render_styles(self, decorated_node, block, blocks):
        node = decorated_node
        if not self.is_empty():
            # Nest the tags.
            for style in sorted(self.styles, reverse=True):
                opt = Options.for_style(self.style_map, style)
                props = dict(opt.props)
                props['block'] = block
                props['blocks'] = blocks
                props['inline_style_range'] = {
                    'style': style,
                }
                node = DOM.create_element(opt.element, props, node)

        return node
 def test_for_style_raises_missing_element(self):
     with self.assertRaises(ConfigException):
         Options.for_style({'BOLD': {}}, 'BOLD')
 def test_for_style_raises_missing_type(self):
     with self.assertRaises(ConfigException):
         Options.for_style({'BOLD': 'strong'}, 'CODE')
 def test_for_style_uses_fallback(self):
     self.assertEqual(Options.for_style({'BOLD': 'strong', 'FALLBACK': 'span'}, 'CODE'), Options('CODE', 'span'))
 def test_for_style_simplest(self):
     self.assertEqual(Options.for_style({'ITALIC': 'em'}, 'ITALIC'), Options('ITALIC', 'em'))