[sphinx-doc] 외부 링크 새 탭(또는 창)에서 열기

Nowaday/유용한 정보 2015. 3. 27. 08:53 Posted by 알 수 없는 사용자


$ sudo vi /usr/local/lib/python2.7/dist-packages/sphinx/writers/html.py


Line 200~

    # overwritten
    def visit_reference(self, node):
        atts = {'class': 'reference'}
   +    isExternal = False
        if node.get('internal') or 'refuri' not in node:
            atts['class'] += ' internal'
        else:
            atts['class'] += ' external'
   +        isExternal = True
        if 'refuri' in node:
            atts['href'] = node['refuri']
   +        if isExternal:
   +            atts['target'] = '"_blank"'
            if self.settings.cloak_email_addresses and \
               atts['href'].startswith('mailto:'):
                atts['href'] = self.cloak_mailto(atts['href'])
                self.in_mailto = 1


AND