mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-09-03 20:52:55 -05:00
Fix #2550: external links are opened in help viewer
This commit is contained in:
@@ -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
|
||||
-------------
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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'):
|
||||
|
||||
Reference in New Issue
Block a user