diff --git a/browse/js/preview-markdown.js b/browse/js/preview-markdown.js index d32126d..a97ba13 100644 --- a/browse/js/preview-markdown.js +++ b/browse/js/preview-markdown.js @@ -456,12 +456,21 @@ var a = document.createElement('a'); a.className = 'btn btn-sm btn-secondary md-shell__download'; a.href = node.url + '?convert=' + encodeURIComponent(fmt); - a.download = node.name.replace(/\.md$/i, '') + '.' + fmt; - a.textContent = fmt.toUpperCase(); - a.title = 'Download as ' + fmt.toUpperCase() - + ' (right-click to copy link or open in new tab)'; - a.dataset.fmt = fmt; + // target=_blank: clicks open in a new tab. The server + // sends Content-Disposition: inline, so the new tab + // either renders (HTML → web page; PDF → browser's + // PDF viewer) or auto-downloads (DOCX, since browsers + // can't render Office Open XML). Right-click "Save + // Link As" still gives a download-to-disk path for + // any format. Errors from the server (422, 503, …) + // appear as a plain-text page in the new tab, which + // is more diagnostic than a transient toast. + a.target = '_blank'; a.rel = 'noopener'; + a.textContent = fmt.toUpperCase(); + a.title = 'Open ' + fmt.toUpperCase() + + ' in a new tab (right-click for Save Link As / Copy Link)'; + a.dataset.fmt = fmt; convertBtns.push(a); }); }