Skip to content

Commit

Permalink
fix: wrong remove intention, make unexpected issue
Browse files Browse the repository at this point in the history
issue: #205
  • Loading branch information
hosseinmd committed Oct 5, 2023
1 parent 08912c3 commit de71607
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/descriptionFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function formatDescription(
let tableIndex = 0;

text = text.replace(
new RegExp("\\n" + "\\s".repeat(beginningSpace.length), "g"),
new RegExp("\\n" + `[\u0020]{${beginningSpace.length}}`, "g"),
"\n",
);

Expand Down
24 changes: 24 additions & 0 deletions tests/__snapshots__/descriptions.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,30 @@ exports[`Markdown link 1`] = `
"
`;
exports[`Markdown table replaced 1`] = `
"/**
* @param options Options object for setting file system flags (default:
* \`"r"\`):
*
* | flags | description |
* | ------- | -------------------------------------------------------------------------------------------------------------- |
* | \`"a"\` | Open file for appending. The file is created if it does not exist. |
* | \`"ax"\` | Like \`"a"\` but fails if the path exists. |
* | \`"a+"\` | Open file for reading and appending. The file is created if it does not exist. |
* | \`"ax+"\` | Like \`"a+"\` but fails if the path exists. |
* | \`"as"\` | Open file for appending in synchronous mode. The file is created if it does not exist. |
* | \`"as+"\` | Open file for reading and appending in synchronous mode. The file is created if it does not exist. |
* | \`"r"\` | Open file for reading. An exception occurs if the file does not exist. |
* | \`"r+"\` | Open file for reading and writing. An exception occurs if the file does not exist. |
* | \`"rs+"\` | Open file for reading and writing in synchronous mode. Instructs the OS to bypass the local file system cache. |
* | \`"w"\` | Open file for writing. The file is created (if it does not exist) or truncated (if it exists). |
* | \`"wx"\` | Like \`"w"\` but fails if the path exists. |
* | \`"w+"\` | Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). |
* | \`"wx+"\` | Like \`"w+"\` but fails if the path exists. |
*/
"
`;
exports[`Nested list 1`] = `
"/**
* 1. Foo
Expand Down
28 changes: 28 additions & 0 deletions tests/descriptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,3 +1056,31 @@ test("Reference-style Links ", async () => {

expect(result).toMatchSnapshot();
});

test("Markdown table replaced ", async () => {
const result = await subject(
`
/**
* @param options Options object for setting file system flags (default: \`"r"\`):
*
* | flags | description |
* | ------- | -------------------------------------------------------------------------------------------------------------- |
* | \`"a"\` | Open file for appending. The file is created if it does not exist. |
* | \`"ax"\` | Like \`"a"\` but fails if the path exists. |
* | \`"a+"\` | Open file for reading and appending. The file is created if it does not exist. |
* | \`"ax+"\` | Like \`"a+"\` but fails if the path exists. |
* | \`"as"\` | Open file for appending in synchronous mode. The file is created if it does not exist. |
* | \`"as+"\` | Open file for reading and appending in synchronous mode. The file is created if it does not exist. |
* | \`"r"\` | Open file for reading. An exception occurs if the file does not exist. |
* | \`"r+"\` | Open file for reading and writing. An exception occurs if the file does not exist. |
* | \`"rs+"\` | Open file for reading and writing in synchronous mode. Instructs the OS to bypass the local file system cache. |
* | \`"w"\` | Open file for writing. The file is created (if it does not exist) or truncated (if it exists). |
* | \`"wx"\` | Like \`"w"\` but fails if the path exists. |
* | \`"w+"\` | Open file for reading and writing. The file is created (if it does not exist) or truncated (if it exists). |
* | \`"wx+"\` | Like \`"w+"\` but fails if the path exists. |
*/
`,
);

expect(result).toMatchSnapshot();
});

0 comments on commit de71607

Please sign in to comment.