mirror of
https://github.com/all-contributors/cli.git
synced 2025-01-25 05:56:28 +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
|
return previousContent
|
||||||
}
|
}
|
||||||
const startIndent = Math.max(
|
const startIndent = Math.max(0, previousContent.lastIndexOf('\n', startOfOpeningTagIndex))
|
||||||
0,
|
const nbSpaces = startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
|
||||||
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${ ' '.repeat(nbSpaces - 1) }<!-- prettier-ignore-start -->`,
|
||||||
'\n<!-- markdownlint-disable -->',
|
`\n${ ' '.repeat(nbSpaces - 1) }<!-- markdownlint-disable -->`,
|
||||||
newContent.replace('\n', `\n${' '.repeat(nbSpaces - 1)}`),
|
' '.repeat(nbSpaces - 1) + newContent.replace('\n', `\n${ ' '.repeat(nbSpaces)}`).replace('</table>', `${' '.repeat(nbSpaces) }</table>`),
|
||||||
'<!-- markdownlint-restore -->',
|
`${' '.repeat(nbSpaces - 1) }<!-- markdownlint-restore -->`,
|
||||||
'\n<!-- prettier-ignore-end -->',
|
`\n${ ' '.repeat(nbSpaces - 1) }<!-- prettier-ignore-end -->`,
|
||||||
'\n\n',
|
'\n\n',
|
||||||
previousContent.slice(startOfClosingTagIndex),
|
' '.repeat(nbSpaces - 1) + previousContent.slice(startOfClosingTagIndex),
|
||||||
].join('')
|
].join('')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,18 +99,14 @@ function replaceBadge(newContent) {
|
||||||
) {
|
) {
|
||||||
return previousContent
|
return previousContent
|
||||||
}
|
}
|
||||||
const startIndent = Math.max(
|
const startIndent = Math.max(0, previousContent.lastIndexOf('\n', startOfOpeningTagIndex))
|
||||||
0,
|
const nbSpaces = startOfOpeningTagIndex - Math.min(startOfOpeningTagIndex, startIndent)
|
||||||
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.replace('\n', `\n${' '.repeat(nbSpaces)}`),
|
' '.repeat(nbSpaces - 1) + newContent.replace('\n', `\n${ ' '.repeat(nbSpaces)}`),
|
||||||
'\n',
|
'\n',
|
||||||
previousContent.slice(startOfClosingTagIndex),
|
' '.repeat(nbSpaces - 1) + previousContent.slice(startOfClosingTagIndex),
|
||||||
].join('')
|
].join('')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue