Example #1
0
def visit_codepen(self, node):
    atts = ['data-embed-version="2"']

    if 'height' in node:
        px = directives.length_or_percentage_or_unitless(node['height'], 'px')
        atts.append('data-height="{}" style="height: {};"'.format(
            node['height'], px))
    else:
        atts.append('data-height="{}" style="height: {};"'.format(
            '265', '265px'))

    if 'author' in node and 'slug' in node:
        atts.append('data-slug-hash="{}"'.format(node['slug']))
        atts.append('data-user="******"'.format(node['author']))

    if 'theme' in node:
        atts.append('data-theme-id="{}"'.format(node['theme']))

    if 'preview' in node:
        atts.append('data-preview="true"')

    if 'tabs' in node:
        atts.append('data-default-tab="{}"'.format(node['tabs']))

    props = " ".join(atts)

    node = '<div class="rst-codepen"><p class="codepen" {}>{}</p></div>'.format(
        props, node['url'])
    self.body.append(node + '\n')

    raise nodes.SkipNode
Example #2
0
 def figwidth_value(argument):
     if argument.lower() == 'image':
         return 'image'
     else:
         return directives.length_or_percentage_or_unitless(argument, 'px')
Example #3
0
 def figwidth_value(argument):
     """Return figure width."""
     if argument.lower() == 'image':
         return 'image'
     else:
         return directives.length_or_percentage_or_unitless(argument, 'px')
Example #4
0
def _clean_px_value(argument):
    return directives.length_or_percentage_or_unitless(argument, "px")
Example #5
0
def figwidth_value(argument):
    if argument.lower() == "image":
        return "image"
    else:
        return directives.length_or_percentage_or_unitless(argument, "px")
Example #6
0
 def figwidth_value(argument):
     return directives.length_or_percentage_or_unitless(argument, "px")
Example #7
0
 def figwidth_value(argument):
     """Return figure width."""
     if argument.lower() == "image":
         return "image"
     else:
         return directives.length_or_percentage_or_unitless(argument, "px")
Example #8
0
 def figwidth_value(argument):
     return spec.length_or_percentage_or_unitless(argument, "px")