mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 13:36:29 +00:00
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>
This commit is contained in:
parent
8db67102cb
commit
7a9150fa52
1 changed files with 14 additions and 2 deletions
|
@ -24,11 +24,17 @@ function injectListBetweenTags(newContent) {
|
||||||
) {
|
) {
|
||||||
return previousContent
|
return previousContent
|
||||||
}
|
}
|
||||||
|
const startIndent = Math.max(
|
||||||
|
0,
|
||||||
|
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
|
||||||
|
)
|
||||||
|
const nbSpaces =
|
||||||
|
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
|
||||||
return [
|
return [
|
||||||
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
|
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
|
||||||
'\n<!-- prettier-ignore-start -->',
|
'\n<!-- prettier-ignore-start -->',
|
||||||
'\n<!-- markdownlint-disable -->',
|
'\n<!-- markdownlint-disable -->',
|
||||||
newContent,
|
newContent.replace('\n', `\n${' '.repeat(nbSpaces - 1)}`),
|
||||||
'<!-- markdownlint-restore -->',
|
'<!-- markdownlint-restore -->',
|
||||||
'\n<!-- prettier-ignore-end -->',
|
'\n<!-- prettier-ignore-end -->',
|
||||||
'\n\n',
|
'\n\n',
|
||||||
|
@ -85,10 +91,16 @@ function replaceBadge(newContent) {
|
||||||
) {
|
) {
|
||||||
return previousContent
|
return previousContent
|
||||||
}
|
}
|
||||||
|
const startIndent = Math.max(
|
||||||
|
0,
|
||||||
|
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
|
||||||
|
)
|
||||||
|
const nbSpaces =
|
||||||
|
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
|
||||||
return [
|
return [
|
||||||
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
|
previousContent.slice(0, endOfOpeningTagIndex + closingTag.length),
|
||||||
'\n',
|
'\n',
|
||||||
newContent,
|
newContent.replace('\n', `\n${' '.repeat(nbSpaces)}`),
|
||||||
'\n',
|
'\n',
|
||||||
previousContent.slice(startOfClosingTagIndex),
|
previousContent.slice(startOfClosingTagIndex),
|
||||||
].join('')
|
].join('')
|
||||||
|
|
Loading…
Reference in a new issue