コード例 #1
0
ファイル: markdown.py プロジェクト: CartoDB/bigmetadata
 def visit_caption(self, node):
     if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
         self.body.append('<div class="code-block-caption">')
     else:
         BaseTranslator.visit_caption(self, node)
     self.add_fignumber(node.parent)
     self.body.append(self.starttag(node, "span", "", CLASS="caption-text"))
コード例 #2
0
ファイル: markdown.py プロジェクト: nikola-mm/bigmetadata
 def visit_caption(self, node):
     if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
         self.body.append('<div class="code-block-caption">')
     else:
         BaseTranslator.visit_caption(self, node)
     self.add_fignumber(node.parent)
     self.body.append(self.starttag(node, 'span', '', CLASS='caption-text'))
コード例 #3
0
ファイル: markdown.py プロジェクト: nikola-mm/bigmetadata
 def __init__(self, builder, *args, **kwds):
     BaseTranslator.__init__(self, *args, **kwds)
 #    self.no_smarty = 0
     self.builder = builder
 #    self.protect_literal_text = 0
     self.permalink_text = builder.config.html_add_permalinks
 #    # support backwards-compatible setting to a bool
     if not isinstance(self.permalink_text, string_types):
         self.permalink_text = self.permalink_text and u'\u00B6' or ''
コード例 #4
0
ファイル: markdown.py プロジェクト: CartoDB/bigmetadata
 def __init__(self, builder, *args, **kwds):
     BaseTranslator.__init__(self, *args, **kwds)
     #    self.no_smarty = 0
     self.builder = builder
     #    self.protect_literal_text = 0
     self.permalink_text = builder.config.html_add_permalinks
     #    # support backwards-compatible setting to a bool
     if not isinstance(self.permalink_text, string_types):
         self.permalink_text = self.permalink_text and u"\u00B6" or ""
コード例 #5
0
ファイル: markdown.py プロジェクト: nikola-mm/bigmetadata
    def depart_caption(self, node):
        self.body.append('</span>')

        # append permalink if available
        if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
            self.add_permalink_ref(node.parent, _('Permalink to this code'))
        elif isinstance(node.parent, nodes.figure):
            image_nodes = node.parent.traverse(nodes.image)
            target_node = image_nodes and image_nodes[0] or node.parent
            self.add_permalink_ref(target_node, _('Permalink to this image'))
        elif node.parent.get('toctree'):
            self.add_permalink_ref(node.parent.parent, _('Permalink to this toctree'))

        if isinstance(node.parent, nodes.container) and node.parent.get('literal_block'):
            self.body.append('</div>\n')
        else:
            BaseTranslator.depart_caption(self, node)
コード例 #6
0
ファイル: markdown.py プロジェクト: CartoDB/bigmetadata
    def depart_caption(self, node):
        self.body.append("</span>")

        # append permalink if available
        if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
            self.add_permalink_ref(node.parent, _("Permalink to this code"))
        elif isinstance(node.parent, nodes.figure):
            image_nodes = node.parent.traverse(nodes.image)
            target_node = image_nodes and image_nodes[0] or node.parent
            self.add_permalink_ref(target_node, _("Permalink to this image"))
        elif node.parent.get("toctree"):
            self.add_permalink_ref(node.parent.parent, _("Permalink to this toctree"))

        if isinstance(node.parent, nodes.container) and node.parent.get("literal_block"):
            self.body.append("</div>\n")
        else:
            BaseTranslator.depart_caption(self, node)
コード例 #7
0
ファイル: markdown.py プロジェクト: nikola-mm/bigmetadata
    def visit_image(self, node):
        olduri = node['uri']
        # rewrite the URI if the environment knows about it
        if olduri in self.builder.images:
            node['uri'] = posixpath.join(self.builder.imgpath,
                                         self.builder.images[olduri])

        uri = node['uri']
        if uri.lower().endswith('svg') or uri.lower().endswith('svgz'):
            atts = {'src': uri}
            if 'width' in node:
                atts['width'] = node['width']
            if 'height' in node:
                atts['height'] = node['height']
            atts['alt'] = node.get('alt', uri)
            if 'align' in node:
                self.body.append('<div align="%s" class="align-%s">' %
                                 (node['align'], node['align']))
                self.context.append('</div>\n')
            else:
                self.context.append('')
            self.body.append(self.emptytag(node, 'img', '', **atts))
            return

        if 'scale' in node:
            # Try to figure out image height and width.  Docutils does that too,
            # but it tries the final file name, which does not necessarily exist
            # yet at the time the HTML file is written.
            if not ('width' in node and 'height' in node):
                size = get_image_size(path.join(self.builder.srcdir, olduri))
                if size is None:
                    self.builder.env.warn_node('Could not obtain image size. '
                                               ':scale: option is ignored.', node)
                else:
                    if 'width' not in node:
                        node['width'] = str(size[0])
                    if 'height' not in node:
                        node['height'] = str(size[1])
        BaseTranslator.visit_image(self, node)
コード例 #8
0
ファイル: markdown.py プロジェクト: CartoDB/bigmetadata
    def visit_image(self, node):
        olduri = node["uri"]
        # rewrite the URI if the environment knows about it
        if olduri in self.builder.images:
            node["uri"] = posixpath.join(self.builder.imgpath, self.builder.images[olduri])

        uri = node["uri"]
        if uri.lower().endswith("svg") or uri.lower().endswith("svgz"):
            atts = {"src": uri}
            if "width" in node:
                atts["width"] = node["width"]
            if "height" in node:
                atts["height"] = node["height"]
            atts["alt"] = node.get("alt", uri)
            if "align" in node:
                self.body.append('<div align="%s" class="align-%s">' % (node["align"], node["align"]))
                self.context.append("</div>\n")
            else:
                self.context.append("")
            self.body.append(self.emptytag(node, "img", "", **atts))
            return

        if "scale" in node:
            # Try to figure out image height and width.  Docutils does that too,
            # but it tries the final file name, which does not necessarily exist
            # yet at the time the HTML file is written.
            if not ("width" in node and "height" in node):
                size = get_image_size(path.join(self.builder.srcdir, olduri))
                if size is None:
                    self.builder.env.warn_node("Could not obtain image size. " ":scale: option is ignored.", node)
                else:
                    if "width" not in node:
                        node["width"] = str(size[0])
                    if "height" not in node:
                        node["height"] = str(size[1])
        BaseTranslator.visit_image(self, node)
コード例 #9
0
ファイル: markdown.py プロジェクト: nikola-mm/bigmetadata
 def visit_bullet_list(self, node):
     if len(node) == 1 and node[0].tagname == 'toctree':
         raise nodes.SkipNode
     BaseTranslator.visit_bullet_list(self, node)
コード例 #10
0
ファイル: markdown.py プロジェクト: CartoDB/bigmetadata
 def visit_bullet_list(self, node):
     if len(node) == 1 and node[0].tagname == "toctree":
         raise nodes.SkipNode
     BaseTranslator.visit_bullet_list(self, node)