mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-09 21:46:29 +00:00
fix: resolve format issues in rst
This commit is contained in:
parent
048b4e304c
commit
7ea56c2768
2 changed files with 37 additions and 45 deletions
|
@ -24,21 +24,17 @@ function injectListBetweenTags(newContent) {
|
|||
) {
|
||||
return previousContent
|
||||
}
|
||||
const startIndent = Math.max(
|
||||
0,
|
||||
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
|
||||
)
|
||||
const nbSpaces =
|
||||
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
|
||||
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.replace('\n', `\n${' '.repeat(nbSpaces - 1)}`),
|
||||
'<!-- markdownlint-restore -->',
|
||||
'\n<!-- prettier-ignore-end -->',
|
||||
`\n${ ' '.repeat(nbSpaces - 1) }<!-- prettier-ignore-start -->`,
|
||||
`\n${ ' '.repeat(nbSpaces - 1) }<!-- markdownlint-disable -->`,
|
||||
' '.repeat(nbSpaces - 1) + newContent.replace('\n', `\n${ ' '.repeat(nbSpaces)}`).replace('</table>', `${' '.repeat(nbSpaces) }</table>`),
|
||||
`${' '.repeat(nbSpaces - 1) }<!-- markdownlint-restore -->`,
|
||||
`\n${ ' '.repeat(nbSpaces - 1) }<!-- prettier-ignore-end -->`,
|
||||
'\n\n',
|
||||
previousContent.slice(startOfClosingTagIndex),
|
||||
' '.repeat(nbSpaces - 1) + previousContent.slice(startOfClosingTagIndex),
|
||||
].join('')
|
||||
}
|
||||
}
|
||||
|
@ -103,18 +99,14 @@ function replaceBadge(newContent) {
|
|||
) {
|
||||
return previousContent
|
||||
}
|
||||
const startIndent = Math.max(
|
||||
0,
|
||||
previousContent.lastIndexOf('\n', startOfOpeningTagIndex),
|
||||
)
|
||||
const nbSpaces =
|
||||
startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
|
||||
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.replace('\n', `\n${' '.repeat(nbSpaces)}`),
|
||||
' '.repeat(nbSpaces - 1) + newContent.replace('\n', `\n${ ' '.repeat(nbSpaces)}`),
|
||||
'\n',
|
||||
previousContent.slice(startOfClosingTagIndex),
|
||||
' '.repeat(nbSpaces - 1) + previousContent.slice(startOfClosingTagIndex),
|
||||
].join('')
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue