Skip to content

Commit

Permalink
feat: Pretty-print the generagted HTML table (#190)
Browse files Browse the repository at this point in the history
Closes #189
Keeps the Table left aligned, and moves the tr and td in by 2 spaces each
  • Loading branch information
nschonni authored and Berkmann18 committed Jun 11, 2019
1 parent 89c3840 commit 68166ec
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/generate/__tests__/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ Description
These people contributed to the project:
<!-- ALL-CONTRIBUTORS-LIST:START -->
<!-- prettier-ignore -->
<table><tr><td align=\\"center\\">Kent C. Dodds is awesome!</td><td align=\\"center\\">Divjot Singh is awesome!</td><td align=\\"center\\">Jeroen Engels is awesome!</td></tr></table>
<table>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Divjot Singh is awesome!</td>
<td align=\\"center\\">Jeroen Engels is awesome!</td>
</tr>
</table>
<!-- ALL-CONTRIBUTORS-LIST:END -->
Expand All @@ -25,7 +31,19 @@ Description
These people contributed to the project:
<!-- ALL-CONTRIBUTORS-LIST:START -->
<!-- prettier-ignore -->
<table><tr><td align=\\"center\\">Kent C. Dodds is awesome!</td><td align=\\"center\\">Kent C. Dodds is awesome!</td><td align=\\"center\\">Kent C. Dodds is awesome!</td><td align=\\"center\\">Kent C. Dodds is awesome!</td><td align=\\"center\\">Kent C. Dodds is awesome!</td></tr><tr><td align=\\"center\\">Kent C. Dodds is awesome!</td><td align=\\"center\\">Kent C. Dodds is awesome!</td></tr></table>
<table>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
</tr>
<tr>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
<td align=\\"center\\">Kent C. Dodds is awesome!</td>
</tr>
</table>
<!-- ALL-CONTRIBUTORS-LIST:END -->
Expand Down
8 changes: 5 additions & 3 deletions src/generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function injectListBetweenTags(newContent) {
}

function formatLine(contributors) {
return `<td align="center">${contributors.join('</td><td align="center">')}</td>`
return `<td align="center">${contributors.join(
'</td>\n <td align="center">',
)}</td>`
}

function generateContributorsList(options, contributors) {
Expand All @@ -46,9 +48,9 @@ function generateContributorsList(options, contributors) {
}),
_.chunk(options.contributorsPerLine),
_.map(formatLine),
_.join('</tr><tr>'),
_.join('\n </tr>\n <tr>\n '),
newContent => {
return `\n<table><tr>${newContent}</tr></table>\n\n`
return `\n<table>\n <tr>\n ${newContent}\n </tr>\n</table>\n\n`
},
)(contributors)
}
Expand Down

0 comments on commit 68166ec

Please sign in to comment.