Fix #2550: external links are opened in help viewer

This commit is contained in:
Takeshi KOMIYA
2016-09-18 17:29:17 +09:00
parent 1e06f0cb70
commit 5f63aac209
3 changed files with 11 additions and 0 deletions
+1
View File
@@ -136,6 +136,7 @@ Bugs fixed
* #2485: autosummary crashes with multiple source_suffix values
* #1734: Could not translate the caption of toctree directive
* Could not translate the content of meta directive (ref: #1734)
* #2550: external links are opened in help viewer
Documentation
-------------
+8
View File
@@ -198,6 +198,14 @@ class HTMLHelpBuilder(StandaloneHTMLBuilder):
def handle_finish(self):
self.build_hhx(self.outdir, self.config.htmlhelp_basename)
def write_doc(self, docname, doctree):
for node in doctree.traverse(nodes.reference):
# add ``target=_blank`` attributes to external links
if node.get('internal') is None and 'refuri' in node:
node['target'] = '_blank'
StandaloneHTMLBuilder.write_doc(self, docname, doctree)
def build_hhx(self, outdir, outname):
self.info('dumping stopword list...')
with self.open_file(outdir, outname+'.stp') as f:
+2
View File
@@ -213,6 +213,8 @@ class HTMLTranslator(BaseTranslator):
atts['class'] += ' image-reference'
if 'reftitle' in node:
atts['title'] = node['reftitle']
if 'target' in node:
atts['target'] = node['target']
self.body.append(self.starttag(node, 'a', '', **atts))
if node.get('secnumber'):