Skip to content

Commit

Permalink
Merge pull request #60 from slhck/fix-markdown
Browse files Browse the repository at this point in the history
fix: markdown list format, fixes #43
  • Loading branch information
RSeidelsohn authored Jan 31, 2023
2 parents f3552fa + 4739bb1 commit a0b4431
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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

0 comments on commit a0b4431

Please sign in to comment.