From d3ca1c5ad532e3ea82caabad8b552572131231e5 Mon Sep 17 00:00:00 2001 From: Kelly Joseph Price Date: Wed, 11 Dec 2024 14:02:19 -0800 Subject: [PATCH] fix: dont treat escapes as flow --- __tests__/migration/tables.test.ts | 17 +++++++++++++++++ processor/migration/index.ts | 10 ++-------- processor/transform/tables-to-jsx.ts | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/__tests__/migration/tables.test.ts b/__tests__/migration/tables.test.ts index 255d5ec8e..50daa6250 100644 --- a/__tests__/migration/tables.test.ts +++ b/__tests__/migration/tables.test.ts @@ -486,4 +486,21 @@ ${JSON.stringify( " `); }); + + it('compiles tables with leading escapes', () => { + const md = ` +| Col 1 | Col 2 | +| --------- | ----- | +| \\_foo_\\ | bar | +`; + + const mdx = migrate(md); + + expect(mdx).toMatchInlineSnapshot(` + "| Col 1 | Col 2 | + | --------- | ----- | + | \\_foo\\_\\ | bar | + " + `); + }); }); diff --git a/processor/migration/index.ts b/processor/migration/index.ts index 02c9907ae..45805ca56 100644 --- a/processor/migration/index.ts +++ b/processor/migration/index.ts @@ -3,12 +3,6 @@ import imagesTransformer from './images'; import linkReferenceTransformer from './linkReference'; import tableCellTransformer from './table-cell'; -const transformers = [ - emphasisTransformer, - imagesTransformer, - linkReferenceTransformer, - tableCellTransformer, -]; - -export default transformers +const transformers = [emphasisTransformer, imagesTransformer, linkReferenceTransformer, tableCellTransformer]; +export default transformers; diff --git a/processor/transform/tables-to-jsx.ts b/processor/transform/tables-to-jsx.ts index 7d401137e..dc423d274 100644 --- a/processor/transform/tables-to-jsx.ts +++ b/processor/transform/tables-to-jsx.ts @@ -36,7 +36,7 @@ const visitor = (table: Table, index: number, parent: Parents) => { parent.children.splice(index, 1, { type: 'text', value: '\n' }); }); - if (!phrasing(content)) { + if (!phrasing(content) && content.type !== 'escape') { hasFlowContent = true; return EXIT; }