Skip to content

Commit

Permalink
fix: dont treat escapes as flow
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjosephprice committed Dec 11, 2024
1 parent 4616fb3 commit d3ca1c5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
17 changes: 17 additions & 0 deletions __tests__/migration/tables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
"
`);
});
});
10 changes: 2 additions & 8 deletions processor/migration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion processor/transform/tables-to-jsx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d3ca1c5

Please sign in to comment.