mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Refactor Notebook Link Handling (#16473)
* add keep absolute paths instead convert setting * update tests/config * refactor links in NotebookLinkHandler
This commit is contained in:
@@ -108,6 +108,8 @@ export class NotebookMarkdownRenderer {
|
||||
return '<img ' + attributes.join(' ') + '>';
|
||||
};
|
||||
renderer.link = (href: string, title: string, text: string): string => {
|
||||
// check for isAbsolute prior to escaping and replacement
|
||||
let hrefAbsolute: boolean = path.isAbsolute(href);
|
||||
href = this.cleanUrl(!markdown.isTrusted, notebookFolder, href);
|
||||
if (href === null) {
|
||||
return text;
|
||||
@@ -120,7 +122,7 @@ export class NotebookMarkdownRenderer {
|
||||
// only remove markdown escapes if it's a hyperlink, filepath usually can start with .{}_
|
||||
// and the below function escapes them if it encounters in the path.
|
||||
// dev note: using path.isAbsolute instead of isPathLocal since the latter accepts resolver (IRenderMime.IResolver) to check isLocal
|
||||
if (!path.isAbsolute(href)) {
|
||||
if (!hrefAbsolute) {
|
||||
href = removeMarkdownEscapes(href);
|
||||
}
|
||||
if (
|
||||
@@ -143,7 +145,7 @@ export class NotebookMarkdownRenderer {
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
return `<a href=${href} data-href="${href}" title="${title || href}">${text}</a>`;
|
||||
return `<a href=${href} data-href="${href}" title="${title || href}" is-absolute=${hrefAbsolute}>${text}</a>`;
|
||||
}
|
||||
};
|
||||
renderer.paragraph = (text): string => {
|
||||
|
||||
Reference in New Issue
Block a user