Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
Make markdown tables work as before
Browse files Browse the repository at this point in the history
  • Loading branch information
Dom Harrington committed Jun 25, 2018
1 parent a6d7db0 commit ba238bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,8 @@ exports[`list items 1`] = `
exports[`should strip out inputs 1`] = `"<div></div>"`;
exports[`tables 1`] = `
"<div class=\\"marked-table\\"><table>
<thead>
<tr>
<th>Tables</th>
<th style=\\"text-align:center\\">Are</th>
<th style=\\"text-align:right\\">Cool</th>
</tr>
</thead>
<tbody>
<tr>
<td>col 3 is</td>
<td style=\\"text-align:center\\">right-aligned</td>
<td style=\\"text-align:right\\">$1600</td>
</tr>
<tr>
<td>col 2 is</td>
<td style=\\"text-align:center\\">centered</td>
<td style=\\"text-align:right\\">$12</td>
</tr>
<tr>
<td>zebra stripes</td>
<td style=\\"text-align:center\\">are neat</td>
<td style=\\"text-align:right\\">$1</td>
</tr>
</tbody>
</table></div>
"
"<div><div class=\\"marked-table\\"><table>
<thead><tr><th>Tables</th><th style=\\"text-align:center\\">Are</th><th style=\\"text-align:right\\">Cool</th></tr></thead>
<tbody><tr><td>col 3 is</td><td style=\\"text-align:center\\">right-aligned</td><td style=\\"text-align:right\\">$1600</td></tr><tr><td>col 2 is</td><td style=\\"text-align:center\\">centered</td><td style=\\"text-align:right\\">$12</td></tr><tr><td>zebra stripes</td><td style=\\"text-align:center\\">are neat</td><td style=\\"text-align:right\\">$1</td></tr></tbody>
</table></div></div>"
`;
4 changes: 2 additions & 2 deletions packages/api-explorer/__tests__/lib/markdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ test('should strip out inputs', () => {
});

test('tables', () => {
expect(markdown(`
expect(shallow(markdown(`
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
`)).toMatchSnapshot();
`)).html()).toMatchSnapshot();
});

test('headings', () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/api-explorer/src/lib/markdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ module.exports = function markdown(text, opts = {}) {
oauth: false,
});
},
table: function({ children }) {
return React.createElement('div', { className: 'marked-table' }, React.createElement('table', null, children));
}
},
})
.processSync(text).contents;
Expand Down

0 comments on commit ba238bb

Please sign in to comment.