1
-
2
- import type { Element , Root , Node } from 'hast' ;
1
+ import type { Element , Root , Node , Text , ElementContent } from 'hast' ;
3
2
import { rehype } from 'rehype' ;
4
3
5
4
const isElement = ( node : Node ) : node is Element => node . type === 'element' ;
@@ -35,7 +34,7 @@ export const processAdvanceSteps = (html: string | undefined, split: SplitType)
35
34
} else {
36
35
// Fallback for 'ol' mode: if content is not a single OL, wrap everything in one step.
37
36
if ( tree . children . length > 0 ) {
38
- const li : Element = { type : 'element' , tagName : 'li' , properties : { } , children : tree . children } ;
37
+ const li : Element = { type : 'element' , tagName : 'li' , properties : { } , children : tree . children as ElementContent [ ] } ;
39
38
tree . children = [ {
40
39
type : 'element' ,
41
40
tagName : 'ol' ,
@@ -56,7 +55,7 @@ export const processAdvanceSteps = (html: string | undefined, split: SplitType)
56
55
57
56
if ( ! hasSeparators ) {
58
57
if ( tree . children . length > 0 ) {
59
- const li : Element = { type : 'element' , tagName : 'li' , properties : { } , children : tree . children } ;
58
+ const li : Element = { type : 'element' , tagName : 'li' , properties : { } , children : tree . children as ElementContent [ ] } ;
60
59
tree . children = [ {
61
60
type : 'element' ,
62
61
tagName : 'ol' ,
@@ -90,7 +89,7 @@ export const processAdvanceSteps = (html: string | undefined, split: SplitType)
90
89
. filter (
91
90
( step ) =>
92
91
step . length > 0 &&
93
- step . some ( ( node ) => isElement ( node ) || ( node . type === 'text' && node . value . trim ( ) !== '' ) ) ,
92
+ step . some ( ( node ) => isElement ( node ) || ( node . type === 'text' && ( node as Text ) . value . trim ( ) !== '' ) ) ,
94
93
)
95
94
. map ( ( stepNodes ) => {
96
95
return {
@@ -114,4 +113,4 @@ export const processAdvanceSteps = (html: string | undefined, split: SplitType)
114
113
115
114
const file = stepsProcessor . processSync ( { value : html } ) ;
116
115
return { html : file . toString ( ) } ;
117
- } ;
116
+ } ;
0 commit comments