From ec7cad8dd007f692cb07d9cc41018e6422ac7896 Mon Sep 17 00:00:00 2001 From: d3m1d0v Date: Thu, 22 Feb 2024 15:49:46 +0300 Subject: [PATCH] fix(Table): correct serialization of the table inside blockquote --- src/extensions/markdown/Table/Table.test.ts | 6 +++--- src/extensions/markdown/Table/TableSpecs/toYfm.ts | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/extensions/markdown/Table/Table.test.ts b/src/extensions/markdown/Table/Table.test.ts index d28e153a..064eb8cc 100644 --- a/src/extensions/markdown/Table/Table.test.ts +++ b/src/extensions/markdown/Table/Table.test.ts @@ -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|', diff --git a/src/extensions/markdown/Table/TableSpecs/toYfm.ts b/src/extensions/markdown/Table/TableSpecs/toYfm.ts index 1da08750..26ed1a14 100644 --- a/src/extensions/markdown/Table/TableSpecs/toYfm.ts +++ b/src/extensions/markdown/Table/TableSpecs/toYfm.ts @@ -4,7 +4,7 @@ import {CellAlign, TableAttrs, TableNode} from '../const'; export const toYfm: Record = { [TableNode.Table]: (state, node) => { state.ensureNewLine(); - state.out += '\n'; + state.write('\n'); state.setNoAutoBlank(); state.renderContent(node); @@ -36,7 +36,8 @@ export const toYfm: Record = { } } - state.write('|\n'); + state.write('|'); + state.ensureNewLine(); state.closeBlock(node); }, @@ -49,17 +50,18 @@ export const toYfm: Record = { [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);