Skip to content

Commit 7a9150f

Browse files
12rambauBerkmann18tenshiAMD
authoredSep 27, 2022
feat: adapt to rst (#301)
Co-authored-by: Maximilian Berkmann <maxieberkmann@gmail.com> Co-authored-by: Angel Aviel Domaoan <13580338+tenshiAMD@users.noreply.github.com>
1 parent 8db6710 commit 7a9150f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎src/generate/index.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,17 @@ function injectListBetweenTags(newContent) {
2424
) {
2525
return previousContent
2626
}
27+
const startIndent = Math.max(
28+
0,
29+
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
30+
)
31+
const nbSpaces =
32+
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
2733
return [
2834
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
2935
'\n<!-- prettier-ignore-start -->',
3036
'\n<!-- markdownlint-disable -->',
31-
newContent,
37+
newContent.replace('\n', `\n${' '.repeat(nbSpaces - 1)}`),
3238
'<!-- markdownlint-restore -->',
3339
'\n<!-- prettier-ignore-end -->',
3440
'\n\n',
@@ -85,10 +91,16 @@ function replaceBadge(newContent) {
8591
) {
8692
return previousContent
8793
}
94+
const startIndent = Math.max(
95+
0,
96+
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
97+
)
98+
const nbSpaces =
99+
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
88100
return [
89101
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
90102
'\n',
91-
newContent,
103+
newContent.replace('\n', `\n${' '.repeat(nbSpaces)}`),
92104
'\n',
93105
previousContent.slice(startOfClosingTagIndex),
94106
].join('')

0 commit comments

Comments
 (0)
Please sign in to comment.