3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-12 11:48:29 +01:00

Answer review: reject ~~ and keep later level-one headings in the tagline, limit the new legs' memory, say portable keeps the content

This commit is contained in:
2026-11-08 11:02:55 +01:00
committed by Lillem4n
parent d84f03f890
commit f8d0391dca
5 changed files with 10 additions and 6 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
const markup = /[`[\]*_<>]/
const markup = /[`[\]*_<>~]/
// The README's first paragraph after the title and the badges.
export function readmeTagline(readme) {
const lines = readme.split('\n').filter((line) => !line.startsWith('# ') && !line.startsWith('[!['))
const lines = readme.split('\n').filter((line, index, all) => index !== all.findIndex((first) => first.startsWith('# ')) && !line.startsWith('[!['))
const start = lines.findIndex((line) => line.trim() !== '')
if (start === -1 || lines[start].startsWith('#')) return { error: 'README.md has no tagline paragraph before its first section', ok: false }
const end = lines.findIndex((line, index) => index > start && line.trim() === '')
+5 -1
View File
@@ -18,8 +18,12 @@ test('refuses a README with no paragraph before its first section', () => {
assert.equal(readmeTagline(`${title}## Install\n`).ok, false)
})
test('refuses a README whose next section follows the badges, whatever its heading level', () => {
assert.equal(readmeTagline(`${title}# Install\n\nRun it with Jira.\n`).ok, false)
})
test('refuses markup, which npm would show as raw characters', () => {
for (const markup of ['`code`', '[link](https://example.com)', '**bold**', '_em_', '<b>x</b>']) {
for (const markup of ['`code`', '[link](https://example.com)', '**bold**', '_em_', '~~old~~', '<b>x</b>']) {
assert.equal(readmeTagline(`${title}Convert ${markup}.\n`).ok, false, markup)
}
})