-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
| [![PR App][icn]][demo] | RM-9793 | | :--------------------: | :-----: | ## 🧰 Changes Changes how tables are saved as JSX. The align attribute is stored on the `Table` component, as well as the table cells: ``` <Table align={["center", "center"]}> <thead> <tr> <th style={{ textAlign: 'center' }}>Hi!</th> <th style={{ textAlign: 'center' }}>Hello!</th> </tr> </thead> <tbody> <tr> <td style={{ textAlign: 'center' }}>Bye!</td> <td style={{ textAlign: 'center' }}>Bye Bye!</td> </tr> </tbody> </Table> ``` It also includes some cleanup of code that's not being used, namely `html`, `esast`, and `hastFromHtml`. `hastFromHtml` was going to be used for search indexing, but I think we're going to switch to much simpler parsing of just the `hast`. ## 🧬 QA & Testing - [Broken on production][prod]. - [Working in this PR app][demo]. [demo]: https://markdown-pr-PR_NUMBER.herokuapp.com [prod]: https://SUBDOMAIN.readme.io [icn]: https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg
- Loading branch information
1 parent
5dd4fa5
commit 1cbb175
Showing
21 changed files
with
357 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { mdast } from '../../../lib'; | ||
import { readdir, readFile } from 'node:fs/promises'; | ||
|
||
describe('mdast transformer', async () => { | ||
const cases = await Promise.all( | ||
(await readdir(__dirname)) | ||
.filter(name => !name.match(/.[tj]sx?/)) | ||
.map(async dirname => { | ||
return { | ||
name: dirname, | ||
mdx: await readFile(`${__dirname}/${dirname}/in.mdx`, { encoding: 'utf8' }), | ||
ast: JSON.parse(await readFile(`${__dirname}/${dirname}/out.json`, { encoding: 'utf8' })), | ||
}; | ||
}), | ||
); | ||
|
||
it.each(cases)('parses $name', ({ mdx, ast }) => { | ||
// @ts-ignore | ||
expect(mdast(mdx)).toStrictEqualExceptPosition(ast); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Table align={["center","center"]}> | ||
<thead> | ||
<tr> | ||
<th> | ||
Heading One | ||
</th> | ||
|
||
<th> | ||
Heading Two | ||
</th> | ||
</tr> | ||
|
||
</thead> | ||
|
||
<tbody> | ||
<tr> | ||
<td> | ||
* list item | ||
* list item | ||
</td> | ||
|
||
<td> | ||
:shrug: | ||
</td> | ||
</tr> | ||
|
||
</tbody> | ||
</Table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
{ | ||
"type": "root", | ||
"children": [ | ||
{ | ||
"align": ["center", "center"], | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "Heading One" | ||
} | ||
], | ||
"type": "paragraph" | ||
} | ||
], | ||
"type": "tableCell" | ||
}, | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "Heading Two" | ||
} | ||
], | ||
"type": "paragraph" | ||
} | ||
], | ||
"type": "tableCell" | ||
} | ||
], | ||
"type": "tableRow" | ||
}, | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"checked": null, | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "list item" | ||
} | ||
], | ||
"type": "paragraph" | ||
} | ||
], | ||
"spread": false, | ||
"type": "listItem" | ||
}, | ||
{ | ||
"checked": null, | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "list item" | ||
} | ||
], | ||
"type": "paragraph" | ||
} | ||
], | ||
"spread": false, | ||
"type": "listItem" | ||
} | ||
], | ||
"ordered": false, | ||
"spread": false, | ||
"start": null, | ||
"type": "list" | ||
} | ||
], | ||
"type": "tableCell" | ||
}, | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"name": "shrug", | ||
"type": "gemoji", | ||
"value": "🤷" | ||
} | ||
], | ||
"type": "paragraph" | ||
} | ||
], | ||
"type": "tableCell" | ||
} | ||
], | ||
"type": "tableRow" | ||
} | ||
], | ||
"type": "tableau" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hello, {user.name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"position": { | ||
"end": { | ||
"column": 8, | ||
"line": 1, | ||
"offset": 7 | ||
}, | ||
"start": { | ||
"column": 1, | ||
"line": 1, | ||
"offset": 0 | ||
} | ||
}, | ||
"type": "text", | ||
"value": "Hello, " | ||
}, | ||
{ | ||
"data": { | ||
"hName": "Variable", | ||
"hProperties": { | ||
"name": "name" | ||
} | ||
}, | ||
"position": { | ||
"end": { | ||
"column": 19, | ||
"line": 1, | ||
"offset": 18 | ||
}, | ||
"start": { | ||
"column": 8, | ||
"line": 1, | ||
"offset": 7 | ||
} | ||
}, | ||
"type": "readme-variable", | ||
"value": "{user.name}" | ||
} | ||
], | ||
"position": { | ||
"end": { | ||
"column": 19, | ||
"line": 1, | ||
"offset": 18 | ||
}, | ||
"start": { | ||
"column": 1, | ||
"line": 1, | ||
"offset": 0 | ||
} | ||
}, | ||
"type": "paragraph" | ||
} | ||
], | ||
"position": { | ||
"end": { | ||
"column": 1, | ||
"line": 2, | ||
"offset": 19 | ||
}, | ||
"start": { | ||
"column": 1, | ||
"line": 1, | ||
"offset": 0 | ||
} | ||
}, | ||
"type": "root" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.