feat: Pretty-print the generagted HTML table (#190)

Closes #189
Keeps the Table left aligned, and moves the tr and td in by 2 spaces each
This commit is contained in:
Nick Schonning 2019-06-11 11:17:51 -04:00 committed by Maximilian Berkmann
parent 89c38407bc
commit 68166eca69
2 changed files with 25 additions and 5 deletions

View file

@ -9,7 +9,13 @@ Description
These people contributed to the project: These people contributed to the project:
<!-- ALL-CONTRIBUTORS-LIST:START --> <!-- ALL-CONTRIBUTORS-LIST:START -->
<!-- prettier-ignore --> <!-- 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 --> <!-- ALL-CONTRIBUTORS-LIST:END -->
@ -25,7 +31,19 @@ Description
These people contributed to the project: These people contributed to the project:
<!-- ALL-CONTRIBUTORS-LIST:START --> <!-- ALL-CONTRIBUTORS-LIST:START -->
<!-- prettier-ignore --> <!-- 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 --> <!-- ALL-CONTRIBUTORS-LIST:END -->

View file

@ -36,7 +36,9 @@ function injectListBetweenTags(newContent) {
} }
function formatLine(contributors) { 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) { function generateContributorsList(options, contributors) {
@ -46,9 +48,9 @@ function generateContributorsList(options, contributors) {
}), }),
_.chunk(options.contributorsPerLine), _.chunk(options.contributorsPerLine),
_.map(formatLine), _.map(formatLine),
_.join('</tr><tr>'), _.join('\n </tr>\n <tr>\n '),
newContent => { newContent => {
return `\n<table><tr>${newContent}</tr></table>\n\n` return `\n<table>\n <tr>\n ${newContent}\n </tr>\n</table>\n\n`
}, },
)(contributors) )(contributors)
} }