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

feat: adapt to rst #301

Merged
merged 12 commits into from
Sep 27, 2022
8 changes: 6 additions & 2 deletions src/generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ function injectListBetweenTags(newContent) {
) {
return previousContent
}
const startIndent = max(0, previousContent.LastIndexOf('\n', startOfOpeningTagIndex))
const nbSpaces = startOfOpeningTagIndex - min(startOfOpeningTagIndex, startIndent)
12rambau marked this conversation as resolved.
Show resolved Hide resolved
return [
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
'\n<!-- prettier-ignore-start -->',
'\n<!-- markdownlint-disable -->',
newContent,
newContent.replace('\n', '\n'+ ' '.repeat(nbSpaces)),
12rambau marked this conversation as resolved.
Show resolved Hide resolved
'<!-- markdownlint-restore -->',
'\n<!-- prettier-ignore-end -->',
'\n\n',
Expand Down Expand Up @@ -84,10 +86,12 @@ function replaceBadge(newContent) {
) {
return previousContent
}
const startIndent = max(0, previousContent.LastIndexOf('\n', startOfOpeningTagIndex))
const nbSpaces = startOfOpeningTagIndex - min(startOfOpeningTagIndex, startIndent)
12rambau marked this conversation as resolved.
Show resolved Hide resolved
return [
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
'\n',
newContent,
newContent.replace('\n', '\n'+ ' '.repeat(nbSpaces)),
12rambau marked this conversation as resolved.
Show resolved Hide resolved
'\n',
previousContent.slice(startOfClosingTagIndex),
].join('')
Expand Down