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
16 changes: 14 additions & 2 deletions src/generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@ function injectListBetweenTags(newContent) {
) {
return previousContent
}
const startIndent = Math.max(
0,
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
)
const nbSpaces =
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
return [
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
'\n<!-- prettier-ignore-start -->',
'\n<!-- markdownlint-disable -->',
newContent,
newContent.replace('\n', `\n${' '.repeat(nbSpaces - 1)}`),
'<!-- markdownlint-restore -->',
'\n<!-- prettier-ignore-end -->',
'\n\n',
Expand Down Expand Up @@ -85,10 +91,16 @@ function replaceBadge(newContent) {
) {
return previousContent
}
const startIndent = Math.max(
0,
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
)
const nbSpaces =
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
return [
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
'\n',
newContent,
newContent.replace('\n', `\n${' '.repeat(nbSpaces)}`),
'\n',
previousContent.slice(startOfClosingTagIndex),
].join('')
Expand Down