writer.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:pymotw3 作者: reingart 项目源码 文件源码
def visit_figure(self, node):
        ids = ''
        if node.get('refuri'):
            ids += self.hypertarget(node['refuri'], withdoc=False, anchor=False)
        for id in sorted(self.pop_hyperlink_ids('figure')):
            ids += self.hypertarget(id, anchor=False)
        if node['ids']:
            ids += self.hypertarget(node['ids'][0], anchor=False)
        if (len(node.children) and
           isinstance(node.children[0], nodes.image) and
           node.children[0]['ids']):
            ids += self.hypertarget(node.children[0]['ids'][0], anchor=False)
        for c in node.children:
            if isinstance(c, nodes.caption):
                caption = c.astext()
                node.caption = caption
                ids += self.hypertarget('figure:%s' % caption,
                                        withdoc=False,
                                        anchor=False)
                break
        self.restrict_footnote(node)

        self.body.append('\\begin{figure}[tb]\\begin{center}')
        # The context is added to the body in depart_figure()
        if ids:
            self.context.append(ids)
        self.context.append('\\end{center}\\end{figure}\n')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号