mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
Fix WYWIWYG Table cell adding new line in table cell (#15594)
* fixes new line in table cell * add test and fix for table head
This commit is contained in:
@@ -176,6 +176,10 @@ export class HTMLMarkdownConverter {
|
||||
replacement: function (content, node, options) {
|
||||
// For elements that aren't lists, convert <br> into its markdown equivalent
|
||||
if (node.parentElement?.nodeName !== 'LI') {
|
||||
// Keeps <br> in table cell/head in order to keep new linehow
|
||||
if (node.parentElement?.nodeName === 'TD' || node.parentElement?.nodeName === 'TH') {
|
||||
return '<br>';
|
||||
}
|
||||
return options.br + '\n';
|
||||
}
|
||||
// One (and only one) line break is ignored when it's inside of a list item
|
||||
|
||||
@@ -260,6 +260,13 @@ suite('HTML Markdown Converter', function (): void {
|
||||
assert.equal(htmlMarkdownConverter.convert(htmlString), `| Test | Test | Test |\n| :-: | --- | --- |\n| test | test | test |\n| test | test | test |\n| test | test | test |\n| test | test | test |`, 'Table with center align column header failed');
|
||||
});
|
||||
|
||||
test('Should transform table to keep <br> for new line in table head and cell', () => {
|
||||
htmlString = '<table>\n<thead>\n<tr>\n<th></th>\n<th></th>\n<th></th>\n</tr>\n</thead>\n<tbody><tr>\n<td>test</td>\n<td>test<br>test</td>\n<td></td>\n</tr>\n</tbody></table>\n';
|
||||
assert.equal(htmlMarkdownConverter.convert(htmlString), `| | | |\n| --- | --- | --- |\n| test | test<br>test | |`, 'Table with new line in cell failed');
|
||||
htmlString = '<table>\n<thead>\n<tr>\n<th>TEST<br>TEST</th>\n<th>TEST</th>\n<th>TEST</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>test</td>\n<td>test</td>\n<td>test</td>\n</tr>\n</tbody></table>\n';
|
||||
assert.equal(htmlMarkdownConverter.convert(htmlString), `| TEST<br>TEST | TEST | TEST |\n| --- | --- | --- |\n| test | test | test |`, 'Table with new line in table head failed');
|
||||
});
|
||||
|
||||
test('Should transform <b> and <strong> tags', () => {
|
||||
htmlString = '<b>test string</b>';
|
||||
assert.equal(htmlMarkdownConverter.convert(htmlString), '**test string**', 'Basic bold test failed');
|
||||
|
||||
Reference in New Issue
Block a user