Skip to content

Commit

Permalink
fix: bold text by stars
Browse files Browse the repository at this point in the history
issue: #91
  • Loading branch information
hosseinmd committed Feb 19, 2021
1 parent 0f5f4f2 commit 306218b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/descriptionFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,14 @@ function formatDescription(
); // Add a signature for new paragraph start with three space

text = text.replace(
/(\n\n+(\s+)?[-*](\s+)?)/g, // `\n\n - ` | `\n\n-` | `\n\n -` | `\n\n- `
// [^*] is for ignore bold text like `**warning**`
/(\n\n+(\s+)?[-*]([^\S\r\n]+|[^*]))/g, // `\n\n - ` | `\n\n-` | `\n\n -` | `\n\n- `
NEW_PARAGRAPH_START_WITH_DASH,
);

text = text.replace(
/\n\s*[-*]\s*/g, // `\n - ` | `\n-` | `\n -` | `\n- `
// [^*] is for ignore bold text like `**warning**`
/\n\s*[-*]([^\S\r\n]+|[^*])/g, // `\n - ` | `\n-` | `\n -` | `\n- `
NEW_LINE_START_WITH_DASH,
);

Expand Down
9 changes: 9 additions & 0 deletions tests/__snapshots__/paragraph.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ exports[`New Lines with star 1`] = `
"
`;

exports[`New Lines with star 2`] = `
"/**
* Some comment text.
*
* **Warning:** I am a warning.
*/
"
`;

exports[`Non-english description with dot 1`] = `
"/**
* Wir brauchen hier eine effizientere Lösung. Die generierten Dateien sind zu groß.
Expand Down
11 changes: 11 additions & 0 deletions tests/paragraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,17 @@ test("New Lines with star", () => {
);

expect(result1).toMatchSnapshot();

const result2 = subject(
`/**
* Some comment text.
*
* **Warning:** I am a warning.
*/
`,
);

expect(result2).toMatchSnapshot();
});

test("# in block code", () => {
Expand Down

0 comments on commit 306218b

Please sign in to comment.