Skip to content

Commit

Permalink
fix: migrating pseudo-lists
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjosephprice committed Oct 28, 2024
1 parent a9dcde3 commit db85e80
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
57 changes: 57 additions & 0 deletions __tests__/migration/tables.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,4 +401,61 @@ ${JSON.stringify(
"
`);
});

it('compiles more examples of emphasis', () => {
const md = `
[block:parameters]
{
"data": {
"h-0": "Action",
"h-1": "Description",
"0-0": "Details",
"0-1": "View additional details such as: \\n_Type_ \\n_Owner_ \\n_Created On_ \\n_Last Modified_ \\n_Last Run_"
},
"cols": 2,
"rows": 1,
"align": [
"left",
"left"
]
}
[/block]
`;

const mdx = rmdx.mdx(rmdx.mdastV6(md));

expect(mdx).toMatchInlineSnapshot(`
"<Table align={["left","left"]}>
<thead>
<tr>
<th style={{ textAlign: "left" }}>
Action
</th>
<th style={{ textAlign: "left" }}>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td style={{ textAlign: "left" }}>
Details
</td>
<td style={{ textAlign: "left" }}>
View additional details such as:\\
*Type*\\
*Owner*\\
*Created On*\\
*Last Modified*\\
*Last Run*
</td>
</tr>
</tbody>
</Table>
"
`);
});
});
2 changes: 1 addition & 1 deletion processor/migration/table-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const magicIndex = (i: number, j: number) => `${i === 0 ? 'h' : `${i - 1}`}-${j}
//
// The following regex attempts to detect this pattern, and we'll convert it to
// something more standard.
const psuedoListRegex = /^(?!([*_]+).*\1$)(?<ws>[ \t]*)\\?([*_])\s*(?<item>.*)$/gm;
const psuedoListRegex = /^(?![ \t]*([*_]+).*\1[ \t]*$)(?<ws>[ \t]*)\\?([*_])\s*(?<item>.*)$/gm;

const migrateTableCells = (vfile: VFile) => (table: Table) => {
let json;
Expand Down

0 comments on commit db85e80

Please sign in to comment.