Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: markdown list format, fixes #43 #60

Merged
merged 1 commit into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ The available items are the following:
You can also give default values for each item.
See an example in [customFormatExample.json](customFormatExample.json).

Note that outputting the license text is not recommended with Markdown formatting, as it can be very long and does not work well with Markdown lists.

<a name="requiring"/>

## Requiring
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ exports.asMarkDown = function asMarkDown(sorted, customFormat) {

if (customFormat && Object.keys(customFormat).length > 0) {
Object.keys(sorted).forEach((sortedItem) => {
text.push(` - **[${sortedItem}](${sorted[sortedItem].repository})**`);
text.push(`- **[${sortedItem}](${sorted[sortedItem].repository})**`);

Object.keys(customFormat).forEach((customItem) => {
text.push(` - ${customItem}: ${sorted[sortedItem][customItem]}`);
Expand All @@ -753,7 +753,7 @@ exports.asMarkDown = function asMarkDown(sorted, customFormat) {
} else {
Object.keys(sorted).forEach((key) => {
const module = sorted[key];
text.push(`[${key}](${module.repository}) - ${module.licenses}`);
text.push(`- [${key}](${module.repository}) - ${module.licenses}`);
});
}

Expand Down
4 changes: 2 additions & 2 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe('main tests', function () {

it('and convert to MarkDown', function () {
const str = checker.asMarkDown(output);
assert.equal(str.split('\n')[0], '[@babel/code-frame@7.16.7](https://github.com/babel/babel) - MIT');
assert.equal(str.split('\n')[0], '- [@babel/code-frame@7.16.7](https://github.com/babel/babel) - MIT');
});
});

Expand Down Expand Up @@ -114,7 +114,7 @@ describe('main tests', function () {
};

const str = checker.asMarkDown(output, format);
assert.equal(str.split('\n')[0], ' - **[@babel/code-frame@7.16.7](https://github.com/babel/babel)**');
assert.equal(str.split('\n')[0], '- **[@babel/code-frame@7.16.7](https://github.com/babel/babel)**');
});
});

Expand Down