dsh-lifecard 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/cordis.patch.yml +64 -0
- package/lib/career.js +98 -0
- package/lib/client.js +633 -18
- package/lib/core.js +20 -3
- package/lib/diary.js +838 -0
- package/lib/index.js +444 -9
- package/lib/novel.js +4 -0
- package/lib/presets.js +30 -0
- package/lib/store.js +98 -12
- package/lib/tavern.js +3 -0
- package/lifecard-tools.js +534 -59
- package/package.json +2 -1
- package/skills/lifecard-diary/SKILL.md +131 -0
package/lib/core.js
CHANGED
|
@@ -598,10 +598,27 @@ export function splitSections(body) {
|
|
|
598
598
|
return out.map((s) => ({ title: s.title, body: s.body.join('\n').replace(/^\n+|\n+$/g, '') }))
|
|
599
599
|
}
|
|
600
600
|
|
|
601
|
-
/**
|
|
601
|
+
/**
|
|
602
|
+
* 取某小节正文;没有就返回空串。
|
|
603
|
+
*
|
|
604
|
+
* **同名小节要全取,不能只取第一份。**
|
|
605
|
+
*
|
|
606
|
+
* 人写东西不是围着我们的格式转的:早上写一段「今天最值得讲的一件事」,
|
|
607
|
+
* 晚上想起一句,很自然会再起一个同名标题接着写。以前这里用 `find` 只取
|
|
608
|
+
* 第一份,第二份在整份重写时被静默删掉,人只会觉得「我写的怎么没了」。
|
|
609
|
+
* 标题尾随多个空格(`## 下一步 `)会被规整成同名——同样得并起来。
|
|
610
|
+
*
|
|
611
|
+
* 用空行连接:正文小节是段落,空行是段落间的自然分隔;一行一条的小节
|
|
612
|
+
* 由 `parseList` 按行切,空行本来就会被跳过。
|
|
613
|
+
*/
|
|
602
614
|
export function sectionBody(sections, title) {
|
|
603
|
-
const
|
|
604
|
-
|
|
615
|
+
const list = Array.isArray(sections) ? sections : []
|
|
616
|
+
const bodies = list
|
|
617
|
+
.filter((s) => s.title === title)
|
|
618
|
+
.map((s) => String(s.body ?? '').trim())
|
|
619
|
+
.filter((body) => body !== '')
|
|
620
|
+
if (bodies.length === 0) return ''
|
|
621
|
+
return bodies.join('\n\n')
|
|
605
622
|
}
|
|
606
623
|
|
|
607
624
|
/**
|