Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
fix(parser): more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
r4zendev committed Dec 21, 2023
1 parent aa3ac44 commit 18076de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
13 changes: 11 additions & 2 deletions readme-parser/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ describe('parse/yaml', function () {
deepEqual(parseResult, {
name: 'Do the thing',
description:
'This is an amazing codemod which does `the thing`\n### WARNING\nThis codemod does the thing\n' +
'This is an amazing codemod which does `the thing`\n\n### WARNING\n\nThis codemod does the thing\n' +
'Following the original msw [upgrade guide](https://mswjs.io/docs/migrations/1.x-to-2.x/#imports), ' +
'there are certain imports that changed their location and/or naming. This codemod will adjust your imports to the new location and naming.\n' +
'- `setupWorker` is now imported from `msw/browser`\n' +
Expand Down Expand Up @@ -253,9 +253,12 @@ describe('parse/yaml', function () {
created-on: ${date.toISOString()}
f_long-description: >-
## Description
\n
This is an amazing codemod which does \`the thing\`
### WARNING
This codemod does the thing
Following the original msw [upgrade guide](https://mswjs.io/docs/migrations/1.x-to-2.x/#imports), there are certain imports that changed their location and/or naming. This codemod will adjust your imports to the new location and naming.
- \`setupWorker\` is now imported from \`msw/browser\`
Expand Down Expand Up @@ -324,6 +327,12 @@ f_estimated-time-saving: >-
tags: automations
updated-on: ${date.toISOString()}
published-on: ${date.toISOString()}
seo:
title: Msw V2 - Do the thing | Intuita Automations
og:title: Msw V2 - Do the thing | Intuita Automations
twitter:title: Msw V2 - Do the thing | Intuita Automations
description: This is an amazing codemod which does \`the thing\`
twitter:card: This is an amazing codemod which does \`the thing\`
`.trim(),
);
});
Expand Down
16 changes: 13 additions & 3 deletions readme-parser/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@ const getTextByHeader = (
idx === 0 &&
(child.type === 'text' || child.type === 'inlineCode')
) {
return `${delimiter}${'#'.repeat(rc.depth)} ${
child.value
}${delimiter}`;
const conditionalDelimiter = delimiter.repeat(
isDescription ? 2 : 1,
);
return `${conditionalDelimiter}${'#'.repeat(
rc.depth,
)} ${child.value}${conditionalDelimiter}`;
}

if (child.type === 'inlineCode') {
Expand Down Expand Up @@ -414,6 +417,7 @@ export const convertToYaml = (
titleWithVersion = `${framework} - ${title}`;
}
}
titleWithVersion = capitalize(titleWithVersion);

const res = `
created-on: ${new Date().toISOString()}
Expand Down Expand Up @@ -452,6 +456,12 @@ f_estimated-time-saving: ${
tags: automations
updated-on: ${new Date().toISOString()}
published-on: ${new Date().toISOString()}
seo:
title: ${titleWithVersion} | Intuita Automations
og:title: ${titleWithVersion} | Intuita Automations
twitter:title: ${titleWithVersion} | Intuita Automations
description: ${description.split('\n').at(0)}
twitter:card: ${description.split('\n').at(0)}
`.trim();

return res;
Expand Down

0 comments on commit 18076de

Please sign in to comment.