Skip to content

Commit 4706bb2

Browse files
authored
Merge pull request #8 from gr2m/include-multiple-paragraphs
Include multiple paragraphs in value
2 parents a86b39a + 0ebcc80 commit 4706bb2

2 files changed

Lines changed: 18 additions & 10 deletions

File tree

dist/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4598,13 +4598,13 @@ function toValue(val) {
45984598
return value;
45994599
}
46004600

4601-
result = body.split('###').filter(Boolean).map(line => {
4601+
result = body.trim().split('###').filter(Boolean).map(line => {
46024602
return line.split(/\r?\n\r?\n/).filter(Boolean).map(item => {
46034603
const line = item.trim();
46044604
if (line.startsWith('- [')) {
46054605
return line.split(/\r?\n/).map(check => {
4606-
const field = check.replace(/- \[[X\s]\]/, '');
4607-
return [`${field}`, check.startsWith('- [X]')]
4606+
const field = check.replace(/- \[[X\s]\]\s+/i, '');
4607+
return [`${field}`, check.toUpperCase().startsWith('- [X] ')]
46084608
})
46094609
}
46104610

@@ -4618,8 +4618,12 @@ result = body.split('###').filter(Boolean).map(line => {
46184618
}
46194619

46204620
return [...prev, curr];
4621-
}, []).map(([key, value]) => {
4622-
return [toKey(key), toValue(value)]
4621+
}, []).map(([key, ...lines]) => {
4622+
4623+
const checkListValue = lines.find(line => Array.isArray(line));
4624+
const value = checkListValue ? toValue(checkListValue) : toValue(...lines)
4625+
4626+
return [toKey(key), value];
46234627
})
46244628

46254629
result.forEach(([key, value]) => {

index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ function toValue(val) {
4949
return value;
5050
}
5151

52-
result = body.split('###').filter(Boolean).map(line => {
52+
result = body.trim().split('###').filter(Boolean).map(line => {
5353
return line.split(/\r?\n\r?\n/).filter(Boolean).map(item => {
5454
const line = item.trim();
5555
if (line.startsWith('- [')) {
5656
return line.split(/\r?\n/).map(check => {
57-
const field = check.replace(/- \[[X\s]\]/, '');
58-
return [`${field}`, check.startsWith('- [X]')]
57+
const field = check.replace(/- \[[X\s]\]\s+/i, '');
58+
return [`${field}`, check.toUpperCase().startsWith('- [X] ')]
5959
})
6060
}
6161

@@ -69,8 +69,12 @@ result = body.split('###').filter(Boolean).map(line => {
6969
}
7070

7171
return [...prev, curr];
72-
}, []).map(([key, value]) => {
73-
return [toKey(key), toValue(value)]
72+
}, []).map(([key, ...lines]) => {
73+
74+
const checkListValue = lines.find(line => Array.isArray(line));
75+
const value = checkListValue ? toValue(checkListValue) : toValue(...lines)
76+
77+
return [toKey(key), value];
7478
})
7579

7680
result.forEach(([key, value]) => {

0 commit comments

Comments
 (0)