Skip to content

Commit

Permalink
Merge pull request #309 from executablebooks/agoose77/feat-table-align
Browse files Browse the repository at this point in the history
feat: support the align attribute in tablecell
  • Loading branch information
agoose77 authored Mar 5, 2024
2 parents a04a70d + a2692c7 commit 539baa2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-dogs-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-react': minor
---

Support align in table cells
9 changes: 7 additions & 2 deletions packages/myst-to-react/src/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,19 @@ const BASIC_RENDERERS: BasicNodeRenderers = {
rowSpan: ifGreaterThanOne(node.rowspan),
colSpan: ifGreaterThanOne(node.colspan),
};
const align = {
'text-left': node.align === 'left',
'text-right': node.align === 'right',
'text-center': node.align === 'center',
};
if (node.header)
return (
<th className={node.class} style={node.style} {...attrs}>
<th className={classNames(node.class, align)} style={node.style} {...attrs}>
<MyST ast={node.children} />
</th>
);
return (
<td className={node.class} style={node.style} {...attrs}>
<td className={classNames(node.class, align)} style={node.style} {...attrs}>
<MyST ast={node.children} />
</td>
);
Expand Down

0 comments on commit 539baa2

Please sign in to comment.