mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Notebook Markdown email rendering fix (#16417)
* fix email WYSIWYG rendering
This commit is contained in:
@@ -134,11 +134,16 @@ export class NotebookMarkdownRenderer {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
// HTML Encode href
|
// HTML Encode href
|
||||||
href = href.replace(/&(?!amp;)/g, '&')
|
let uri = URI.parse(href);
|
||||||
.replace(/</g, '<')
|
// mailto uris do not need additional encoding of &, otherwise it would not render properly
|
||||||
.replace(/>/g, '>')
|
if (uri.scheme !== 'mailto') {
|
||||||
.replace(/"/g, '"')
|
href = href.replace(/&(?!amp;)/g, '&');
|
||||||
.replace(/'/g, ''');
|
} else {
|
||||||
|
href = href.replace(/</g, '<')
|
||||||
|
.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}">${text}</a>`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,6 +69,21 @@ suite('NotebookMarkdownRenderer', () => {
|
|||||||
assert.strict(markedPath, '<p>....\test.ipynb</p>');
|
assert.strict(markedPath, '<p>....\test.ipynb</p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('email in markdown format renders properly', () => {
|
||||||
|
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[test@email.com](mailto:test@email.com)`, isTrusted: true });
|
||||||
|
assert.strictEqual(result.innerHTML, `<p><a href="mailto:test@email.com" data-href="mailto:test@email.com" title="mailto:test@email.com">test@email.com</a></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('email inserted directly renders properly', () => {
|
||||||
|
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `test@email.com`, isTrusted: true });
|
||||||
|
assert.strictEqual(result.innerHTML, `<p><a href="mailto:test@email.com" data-href="mailto:test@email.com" title="mailto:test@email.com">test@email.com</a></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('link to https with query parameters', () => {
|
||||||
|
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[test](https://www.test.com?test=&test2=)`, isTrusted: true });
|
||||||
|
assert.strictEqual(result.innerHTML, `<p><a href="https://www.test.com?test=&test2=" data-href="https://www.test.com?test=&test2=" title="https://www.test.com?test=&test2=">test</a></p>`);
|
||||||
|
});
|
||||||
|
|
||||||
test('cell attachment image', () => {
|
test('cell attachment image', () => {
|
||||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: ``, isTrusted: true }, { cellAttachments: JSON.parse('{"ads.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAggg=="}}') });
|
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: ``, isTrusted: true }, { cellAttachments: JSON.parse('{"ads.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAggg=="}}') });
|
||||||
assert.strictEqual(result.innerHTML, `<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAggg==" alt="altText"></p>`, 'Cell attachment basic test failed when trusted');
|
assert.strictEqual(result.innerHTML, `<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAggg==" alt="altText"></p>`, 'Cell attachment basic test failed when trusted');
|
||||||
|
|||||||
Reference in New Issue
Block a user