Skip to content

Commit

Permalink
fix(Table): correct serialization of the table inside blockquote
Browse files Browse the repository at this point in the history
  • Loading branch information
d3m1d0v committed Feb 22, 2024
1 parent 69344e3 commit ec7cad8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/extensions/markdown/Table/Table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ describe('Table extension', () => {
);
});

// TODO: fix it
it.skip('should parse table under blockquoute', () => {
it('should parse table under blockquoute', () => {
const markup = [
'',
'> ',
'> ',
'> |Header 1|Header 2|Header 3|',
'> |:---|:---:|---:|',
'> |Text 1|Text 2|Text 3|',
Expand Down
12 changes: 7 additions & 5 deletions src/extensions/markdown/Table/TableSpecs/toYfm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {CellAlign, TableAttrs, TableNode} from '../const';
export const toYfm: Record<TableNode, SerializerNodeToken> = {
[TableNode.Table]: (state, node) => {
state.ensureNewLine();
state.out += '\n';
state.write('\n');

state.setNoAutoBlank();
state.renderContent(node);
Expand Down Expand Up @@ -36,7 +36,8 @@ export const toYfm: Record<TableNode, SerializerNodeToken> = {
}
}

state.write('|\n');
state.write('|');
state.ensureNewLine();

state.closeBlock(node);
},
Expand All @@ -49,17 +50,18 @@ export const toYfm: Record<TableNode, SerializerNodeToken> = {
[TableNode.Row]: (state, node) => {
state.renderContent(node);
state.closeBlock(node);
state.out += '|\n';
state.write('|');
state.ensureNewLine();
},

[TableNode.HeaderCell]: (state, node) => {
state.out += '|';
state.write('|');
state.renderInline(node);
state.closeBlock(node);
},

[TableNode.DataCell]: (state, node) => {
state.out += '|';
state.write('|');

state.renderInline(node);
state.closeBlock(node);
Expand Down

0 comments on commit ec7cad8

Please sign in to comment.