Skip to content

Commit

Permalink
feat: adapt to rst (#301)
Browse files Browse the repository at this point in the history
Co-authored-by: Maximilian Berkmann <maxieberkmann@gmail.com>
Co-authored-by: Angel Aviel Domaoan <13580338+tenshiAMD@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 27, 2022
1 parent 8db6710 commit 7a9150f
Showing 1 changed file with 14 additions and 2 deletions.
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

0 comments on commit 7a9150f

Please sign in to comment.