@byline/cli 4.4.1 → 4.5.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.
@@ -1,14 +1,20 @@
1
1
  import type { SerializedLexicalNode } from '../richtext-lexical/serialize/types.ts'
2
2
 
3
- export function extractHeadingText(nodes?: SerializedLexicalNode[], text: string = ''): string {
4
- if (nodes != null) {
5
- for (const node of nodes) {
6
- if (node.type === 'text' && node.text != null) {
7
- text = text + node.text
8
- }
9
- if (node.children != null) {
10
- extractHeadingText(node.children, text)
11
- }
3
+ /**
4
+ * Flatten a heading node's descendants to their plain text. Walks the whole
5
+ * subtree, so nested formatting — bold, inline code, a link — contributes its
6
+ * text too, which keeps the derived anchor id stable for such headings.
7
+ */
8
+ export function extractHeadingText(nodes?: SerializedLexicalNode[]): string {
9
+ if (nodes == null) return ''
10
+
11
+ let text = ''
12
+ for (const node of nodes) {
13
+ if (node.type === 'text' && node.text != null) {
14
+ text = text + node.text
15
+ }
16
+ if (node.children != null) {
17
+ text = text + extractHeadingText(node.children)
12
18
  }
13
19
  }
14
20
  return text
@@ -1,14 +1,20 @@
1
1
  import type { SerializedLexicalNode } from './types.ts'
2
2
 
3
- export function extractHeadingText(nodes?: SerializedLexicalNode[], text: string = ''): string {
4
- if (nodes != null) {
5
- for (const node of nodes) {
6
- if (node.type === 'text' && node.text != null) {
7
- text = text + node.text
8
- }
9
- if (node.children != null) {
10
- extractHeadingText(node.children, text)
11
- }
3
+ /**
4
+ * Flatten a heading node's descendants to their plain text. Walks the whole
5
+ * subtree, so nested formatting — bold, inline code, a link — contributes its
6
+ * text too. Kept in step with `../../heading-anchor/utils.ts`.
7
+ */
8
+ export function extractHeadingText(nodes?: SerializedLexicalNode[]): string {
9
+ if (nodes == null) return ''
10
+
11
+ let text = ''
12
+ for (const node of nodes) {
13
+ if (node.type === 'text' && node.text != null) {
14
+ text = text + node.text
15
+ }
16
+ if (node.children != null) {
17
+ text = text + extractHeadingText(node.children)
12
18
  }
13
19
  }
14
20
  return text
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@byline/cli",
3
3
  "private": false,
4
4
  "license": "MPL-2.0",
5
- "version": "4.4.1",
5
+ "version": "4.5.0",
6
6
  "engines": {
7
7
  "node": ">=20.9.0"
8
8
  },